Domanda

Let's say I have a canvas with stuff on it, and I want to carve an ellipse in it's center, whose all of the pixels have an alpha of 0, to let everything behind the canvas to pass through, and given that previously the area now filled by the ellipse was something else, and said that, for performance reasons, I don't want to use putImageData, how would I do so? And if there isn't a way, how would I carve an ellipse using putImageData?

Just to make it clear: I don't want to draw the html elements on the canvas, I want them to simply be in html behind it

È stato utile?

Soluzione

you can use context.globalCompositeOperation = 'destination-out' after you draw the frame to fill the clipped shape(s).

example: http://jsfiddle.net/rlemon/6nEpc/

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top