在画布上旋转
我正在画布上画一些形状,但旋转让我感到害怕。从教程中,我发现由于我愚蠢的头脑而找不到解决方案,或者它们没有显示交互式转换,或者两者兼而有之。
我编写了使用 mousedown
-mousemove
-mouseup
事件绘制一些形状的代码,但我想在 mousemove
时旋转> 点位于... (x1, y1)
- 起点和(x2, y2)
终点。请随意升级下面的代码:
context.strokeRect(x1, y1, x2-x1, y2-y1);
那么,在按住按钮的同时,我到底可以为这些矩形编写什么来跟随点 (x2, y2)
呢?
I'm drawing some shapes on canvas, but rotation freaks me up. From tutorials I found cannot find solution because of my stupid head or they are not showing interactive transformation, or both.
I made the code that draws some shapes with mousedown
-mousemove
-mouseup
events, but I want to rotating while mousemove
point is on... (x1, y1)
- starting point and (x2, y2)
ending point. Please be free to upgrade the code below:
context.strokeRect(x1, y1, x2-x1, y2-y1);
So what exactly could I write for those rectangles to follow point (x2, y2)
while holding the button?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案,请按照代码操作:
I found solution, follow the code: