+ 1
clearing a canvas partially
hypothetical i have a canvas, and that canvas is ontop of an image, the canvas is being drawn on constantly per frame... how do i clear the canvas partially, not completely clearing it, the parts being cleared should not be completely cleared, like slightly lower the opacity, and the image is needed to be visible except its drawn over in the canvas. (drawing the image on the canvas is not viable)
3 ответов
+ 1
It sounds to me like you may need a buffer canvas.
Have the main canvas hold the image. Place the buffer canvas directly over the main canvas. Apply changes to the buffer canvas during the click down event and then on click up apply the buffer canvas to the main and clear the buffer. With the right fiddling, you get an undo-redo mechanism out of it.
0
clearRect() only clears the specified part of the canvas.
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clearRect
0
You can use reset() to clear the hole canvas.