a bit better performance

This commit is contained in:
Anton Lavrenov
2023-04-17 09:55:10 -05:00
parent d18d528d45
commit 6921855566
5 changed files with 29 additions and 19129 deletions

View File

@@ -37,20 +37,21 @@
});
const layer = new Konva.Layer();
stage.add(layer);
const rect = new Konva.Rect({
x: 0,
y: 0,
width: 100,
height: 100,
fill: 'red',
filters: [Konva.Filters.Blur],
blurRadius: 10,
});
layer.add(rect);
rect.cache();
setInterval(() => {
rect.blurRadius(rect.blurRadius() + 1);
}, 100);
console.time('load');
for (var i = 0; i < 30000; i++) {
const shape = new Konva.Circle({
x: Math.random() * stage.width(),
y: Math.random() * stage.height(),
radius: 10,
draggable: true,
fill: Konva.Util.getRandomColor(),
});
layer.add(shape);
}
console.timeEnd('load');
console.time('draw');
layer.draw();
console.timeEnd('draw');
</script>
</body>
</html>