我可以使用jQuery绘制一行吗? [英] Can I draw a line using jQuery?

查看:105
本文介绍了我可以使用jQuery绘制一行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网络应用程序,我想让用户以如下方式绘制一条线:当他点击 Point1 ,他移动鼠标,从 Point1 当前鼠标位置,当点击 Point2 时,最后一行从Point1到Point2

I have a web app where I would like the user to draw a line in the following way: When he clicks on Point1 and he moves the mouse, draw the line from Point1 to the current mouse position and, when clicks to Point2 draw the final line from Point1 to Point2.

我该如何使用jQuery和/或其插件之一?

How can I do it using jQuery and/or one of its plugins?

推荐答案

接受挑战。

我试图用CSS转换和一堆数学在Javascript - 半小时后我有这个:

I tried to do it with CSS transforms and a bunch of Math in Javascript - after half an hour I have this:

http://jsfiddle.net/VnDrb/2/

在灰色方块中点击2次,应该绘制一条线。
当角度大于45度时,仍有一个小错误画出线条错误。也许有人知道如何解决这个问题。也许不是使用Math.asin(arcsinus),使用其他三角函数,但我真的不擅长它。
我想我会发布,即使有一个小bug,我认为这是一个很好的开始。

Make 2 clicks into the gray square and a line should be drawn. There is still a small bug that draws the line wrong when the angle is > 45 degree. Maybe someone else knows how to fix that. Maybe instead of using Math.asin (arcsinus), use a other trigonometrical function, but I'm really not good at it. I thought I'd post it even there is a small bug, I think it's a good start for you.

这篇关于我可以使用jQuery绘制一行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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