Im trying to clear the layer from every circle and line (remove it pletely) but keep the image in the background.
If I use layer.clear()
it removes the image also.
Question: How to clear the layer but avoid removing the image?
Im trying to clear the layer from every circle and line (remove it pletely) but keep the image in the background.
If I use layer.clear()
it removes the image also.
Question: How to clear the layer but avoid removing the image?
https://codesandbox.io/s/sharp-night-t4vtt
Share Improve this question asked Sep 3, 2019 at 10:18 PatrickkxPatrickkx 1,8809 gold badges38 silver badges66 bronze badges1 Answer
Reset to default 4layer.clear()
do not remove objects from the scene. It is just clear canvas element and on the next layer.draw()
all objects will be drawn again.
Instead of layer.clear()
you need to remove objects, that you don't need anymore. From the demo, I see that you need to remove lines and circles. You can use layer.find(selector)
to find that nodes and destroy them.
document.getElementById("btn").addEventListener("click", () => {
layer.find('Line').destroy();
layer.find('Circle').destroy();
layer.draw();
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745246559a4618436.html
评论列表(0条)