javascript JS 在两点或更多点之间画线

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17777362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 09:35:38  来源:igfitidea点击:

JS Draw line between two or more points

javascriptdrawing

提问by Marek123

i need to draw a line between two tags or tags.

我需要在两个标签或标签之间画一条线。

Example:
http://caitriona.github.io/connect-the-dots/

示例:http:
//caitriona.github.io/connect-the-dots/

I need to do something like this but not like in this script, in an order but randomly.
You can click on "P1" and then on "P2" and the line will be drawn. But if you click on "P1" and then on "P3" an error message should appear (that's not the problem).

我需要按顺序但随机地做这样的事情,但不像在这个脚本中那样。
您可以单击“P1”,然后单击“P2”,线将被绘制。但是,如果您单击“P1”,然后单击“P3”,则会出现一条错误消息(这不是问题)。

My problem is, that I'm not so much a javascript crack to draw the line between the points.

我的问题是,我不是一个 javascript 破解者来画点之间的线。

Can someone point me to the right direction?
Thank you!

有人可以指出我正确的方向吗?
谢谢!

回答by mohamed.ahmed

Take a look at drawing in browser SVG (Scalable Vector Graphics). http://www.w3schools.com/graphics/svg_line.asp

看看在浏览器 SVG(可缩放矢量图形)中绘图。http://www.w3schools.com/graphics/svg_line.asp

You can do some pretty interesting stuff with it. Go through the W3Schools tutorial. Let me know how it goes.

你可以用它做一些非常有趣的事情。浏览 W3Schools 教程。让我知道事情的后续。