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
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Incremental Rendering</title>
<script src="../dist/zrender.js"></script>
</head>
<body style="margin:0px;">
<canvas id="main" width="1000px" height="600px" style="width:1000px;height:600px;"></canvas>
<script type="text/javascript">
var zr = zrender.init(document.getElementById('main'));
zr.add(new zrender.Rect({
shape: {
x: 0,
y: 0,
width: zr.getWidth(),
height: zr.getHeight()
},
style: {
fill: 'red'
}
}));
var countText = new zrender.Text({
zlevel: 1,
style: {
text: 10000,
x: 10,
y: 10,
textFont: '40px sans-serif',
textFill: '#fff',
textStroke: '#000',
textStrokeWidth: 2
}
});
zr.add(countText);
var group = new zrender.Group();
zr.add(group);
for (var i = 0; i < 10000; i++) {
var circleShape = new zrender.Circle({
shape: {
r: 5 + Math.random() * 5
},
style: {
fill: '#121',
blend: 'lighter'
},
incremental: true,
position: [Math.random() * zr.getWidth(), Math.random() * zr.getHeight()]
});
group.add(circleShape);
}
countText.dirty();
</script>
</body>
</html>
|