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
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>globalScaleRatio</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%;
}
#global-scale-ratio {
position: absolute;
left: 10px;
top: 10px;
width: 100px;
}
</style>
</head>
<body>
<div id="main"></div>
<input type="range" id="global-scale-ratio" min="0" max="2" value="1" step="0.1">
<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 circle = new zrender.Circle({
position: [300, 300],
scale: [1, 1],
shape: {
cx: 0,
cy: 0,
r: 50
},
style: {
fill: gradient,
lineWidth: 5,
text:'circle',
textPosition:'inside'
}
});
zr.add(circle);
circle.animate('', true)
.when(0, {
scale: [1, 1]
})
.when(1000, {
scale: [3, 3]
})
.when(2000, {
scale: [1, 1]
})
.start();
document.getElementById('global-scale-ratio').addEventListener('change', function (e) {
circle.globalScaleRatio = this.value;
});
</script>
</body>
</html>
|