开发者

why do you have to translate before rotating to rotate an element around himself in canvas?

开发者 https://www.devze.com 2023-03-10 07:13 出处:网络
I just started studying about HTML5element and while trying to figure out how to rotate an element around himself I stumbled across a post saying that you have to translate the origin before rotating

I just started studying about HTML5 element and while trying to figure out how to rotate an element around himself I stumbled across a post saying that you have to translate the origin before rotating the element, and i was wonderin开发者_如何学运维g why is that? isn't translating just moves the origin from which you draw things to another point in the canvas?


You're not rotating the element, but the whole canvas. The canvas point of origin is in it's left-top corner. Translating to (-or actually, the oposite negative direction) your element first, would virtually translate the point of origin.

0

精彩评论

暂无评论...
验证码 换一张
取 消