canvasfabricjsgetimagedataputimagedata

Image data fabric.js


I'm currently working with fabric.js and I succeeded to spherize part of an image after an onclick event.

Problem is the canvas doesn't memorize my actions. When you click once, all is fine, the part spherize. But when you click another time, elsewhere for example, the previous sphere disappear and the new one appear.

When I use console.log to echo the image pixel data, it is the same before and after spherization and I don't understand why.

Here is a fiddle to show you the situation:

[https://jsfiddle.net/2xp8mynz/3/][1]

Thank you so much for your help!


Solution

  • canvas render oImg each time. Therefore, it is necessary to change data of oImg, not canvas.

    I write code in jsfiddle. https://jsfiddle.net/sapics/2xp8mynz/13/