SVG用一条线连接两点

标签 svg line draw jquery-svg

有什么方法可以使用 SVG 中的一条线连接两个点。我有以下内容在 SVG 中创建点。

<?xml version="1.0" standalone="no"?>

<svg width="200px" height="200px" version="1.1" xmlns="http://www.w3.org/2000/svg">

  <path d="M10 10"/>

  <!-- Points -->

  <circle cx="10" cy="10" r="2" fill="red"/>
  <circle cx="90" cy="90" r="2" fill="red"/>
  <circle cx="90" cy="10" r="2" fill="red"/>
  <circle cx="10" cy="90" r="2" fill="red"/>

</svg>

我需要使用 jquery 函数在点之间画一条线。

最佳答案

您可以使用一行:

<line x1="10" y1="10" x2="90" y2="90" stroke-width="1" stroke="black"/>

或者一条路径:
<path d="M10 10 90 90" stroke-width="1" stroke="black"/>

为什么需要jQuery?

关于SVG用一条线连接两点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17272907/

相关文章:

ios - 使用 Sprite Kit 在 Swift 中绘制直线,创建多条线

batch-file - windows批处理文件编程

image - Matlab:在不同坐标上的单轴上绘制多个图像

svg - 您可以将多个 svg 与不同的 viewBox 结合起来并在 Polymer 中自定义每个吗?

IOS/objective-C : Center Line under Button Programmatically

android-studio - 如何在谷歌地图中使用标记和折线的中点绘制多边形

python - 通过共享节点属性定位 networkx 节点

html - 垂直对齐 SVG 图标旁边的文本

css - SVG 笔划破折号数组 CSS 动画反转类(class)?

javascript - SVG:通过 jQuery 更新在 FF 中有效,但在 Safari 中无效,有什么想法吗?