Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 将SVG路径数据导入Raphael.js_Html_Raphael - Fatal编程技术网

Html 将SVG路径数据导入Raphael.js

Html 将SVG路径数据导入Raphael.js,html,raphael,Html,Raphael,我在胡闹,想把一些SVG导入Raphael对象。我查看了一些推特帖子,他说你可以复制粘贴路径点并使用它们。不幸的是,我不能让它工作 我只想做一个简单的svg: <svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="841.89px" height="595.28px" viewB

我在胡闹,想把一些
SVG
导入Raphael对象。我查看了一些推特帖子,他说你可以复制粘贴路径点并使用它们。不幸的是,我不能让它工作

我只想做一个简单的svg:

<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
 width="841.89px" height="595.28px" viewBox="0 0 841.89 595.28" enable-background="new 0 0 841.89 595.28" xml:space="preserve">
<polyline fill="#CBBBA0" stroke="#000000" stroke-miterlimit="10" points="272.343,345.194 307.418,535.492 349.955,342.955 "/>
<circle fill="#E30613" stroke="#000000" stroke-miterlimit="10" cx="277.194" cy="282.881" r="62.313"/>
</svg>
真倒霉!不起作用


谢谢,这是因为您看到的是多边形/多段线,而不是路径

多段线
转换为
路径
d
(定义)。然后你会得到一个拉斐尔理解的路径字符串

可以将路径定义与多边形或多段线定义相对,因为


为方便起见,下面是关于上述链接问题的代码的JSBIN演示,您可以在其中复制、粘贴和转换任何SVG多边形或多段线:


非常好的解决方法。谢谢你,但接下来又有一个问题。圆或椭圆有类似的东西吗,或者我必须每只手做一个吗?例如,使用
attr()
并用圆圈值填充它,等等?有一些工具可以自动将SVG转换为Raphael,我在多年前回答一个问题时写了一些。。。在这里,
var paper = Raphael(10, 50, 320, 200);
paper.path(["272.343,345.194 307.418,535.492 349.955,342.955"])