简体   繁体   English

canvas在canvas.clear()上变得不完全清晰

[英]canvas getting not clear completely on canvas.clear()

I am using canvas for creating shapes like (circle,square,etc) and I need to clear the canvas, I have tried with canvas.clear() it shows empty array when checked with canvas.getObjects() but still shapes are visible and sometimes extra shapes as well. 我使用的画布一样(圆形,方形等)创造的形状,我需要清除画布,我试图与canvas.clear()这表明当检查空数组canvas.getObjects()但仍然形状是可见的,有时还有其他形状。

circle

canvas objects 画布对象

clear canvas 透明帆布

shape still visible 形状仍然可见

extra boundary as well 额外的边界

I have also checked if there is any reference issue, but no only one canvas object. 我还检查了是否存在任何参考问题,但仅检查了一个画布对象。

can anyone give direction what can be the reason, or I have missed something. 任何人都可以指示原因,或者我错过了什么。

Thanks 谢谢

After more and more debugging, it comes out to be some overlay issue. 经过越来越多的调试后,这成为一些覆盖问题。 Actually when shape is added to canvas, two more things are done 实际上,将形状添加到画布后,还要完成两件事

  1. setting overlay for shape 设置形状的叠加
  2. clipping the region 裁剪区域

so somehow on loading JSON, extra layers were appearing on the screen. 因此以某种方式加载JSON时,屏幕上会出现额外的图层。 SO fixed the overlay for shape and clipping again when JSON got loaded, and it worked. SO修复了JSON加载后再次覆盖形状和剪切的问题,并且可以正常工作。

PS: There might be some reference issue as well, because when I do canvas.clear() then canvas.getObjects().length shows 0, but still shapes visible to canvas. PS:可能有一些参考的问题为好,因为当我做canvas.clear()然后canvas.getObjects().length显示0,但至今仍然影响着可见的画布。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM