1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Animation</title>
<script src="../dist/zrender.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
html, body, #main {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="main"></div>
<script type="text/javascript">
var main = document.getElementById('main');
// 初始化zrender
var zr = zrender.init(main);
var gradient = new zrender.LinearGradient();
gradient.addColorStop(0, 'red');
gradient.addColorStop(1, 'black');
var gradient2 = new zrender.LinearGradient();
gradient2.addColorStop(0, 'black');
gradient2.addColorStop(0.5, 'blue');
gradient2.addColorStop(1, 'white');
var circle = new zrender.Circle({
position: [100, 100],
scale: [1, 1],
shape: {
cx: 50,
cy: 50,
r: 50
},
style: {
fill: gradient,
lineWidth: 5
},
textContent: new zrender.Text({
style: {
fill: 'white',
text: 'Circle'
}
}),
textConfig: {
position: 'inside'
}
});
zr.add(circle);
circle.animate('')
.when(200, {
position: [200, 0]
})
.start();
circle.animate('style', true)
.when(1000, {
fill: gradient2
})
.start();
circle.animate('', true)
.when(1000, {
position: [200, 0]
})
.when(2000, {
position: [200, 200]
})
.when(3000, {
position: [0, 200]
})
.when(4000, {
position: [100, 100]
})
.start();
</script>
</body>
</html>
|