简体   繁体   中英

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.

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. SO fixed the overlay for shape and clipping again when JSON got loaded, and it worked.

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.

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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