문제

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

도움이 되었습니까?

해결책

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

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top