如何在画布上移动矩形 [英] How to move rectangle on canvas

查看:87
本文介绍了如何在画布上移动矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JavaScript在我的应用程序中使用canvas。在那个画布上我绘制了一个矩形。我想在鼠标的帮助下移动矩形(例如移动滑块)如何使用JavaScript或J-query移动该矩形。

I use canvas in my application using JavaScript. On that canvas I draw one rectangle. I want to move rectangle with the help of mouse(e.g moving slider) how to move that rectangle using JavaScript or J-query.

推荐答案

Canvas实际上只是你画的一个表面而且你画的东西都不是对象。

A Canvas is literally just a surface that you paint on and none of the things you paint are objects.

如果你想假装它们是物体(比如四处走动)一个矩形或一条线)然后你需要跟踪一切并进行所有热门测试并重新绘画。

If you want to pretend they are objects (like moving around a rectangle or a line) then you need to keep track of everything and do all the hit-testing and re-painting yourself .

I写了一篇温和的介绍文章,开始制作你可以选择的矩形然后拖着走。给那个读。

I wrote a gentle introduction article on getting started by making rectangles that you can select and drag around. Give that a read.

这篇关于如何在画布上移动矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆