Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.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
Web applications SVG简单绘图工具_Web Applications_Svg_Onclick_Fill_Sketching - Fatal编程技术网

Web applications SVG简单绘图工具

Web applications SVG简单绘图工具,web-applications,svg,onclick,fill,sketching,Web Applications,Svg,Onclick,Fill,Sketching,我在线收集了SVG格式的模式。 现在我认为在线绘制它们会很酷,至少用SVG填充一些“onclick=fill”的内容 我找不到这方面的教程,不知道你能否帮我设置这方面的代码 以下是SVG格式的网格示例: <?xml version="1.0" encoding="utf-8"?> <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> &

我在线收集了SVG格式的模式。

现在我认为在线绘制它们会很酷,至少用SVG填充一些“onclick=fill”的内容

我找不到这方面的教程,不知道你能否帮我设置这方面的代码

以下是SVG格式的网格示例:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<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="50%"
 viewBox="0 0 800 600" preserveAspectRatio="xMidYMid slice" width="100%" height="100%" enable-background="new 0 0 800 600" xml:space="preserve">

<polygon fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" points="653.458,599.182 653.458,585.273 
665.501,592.229 677.546,599.182 665.501,606.135 653.458,613.09 "/>
<polygon fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" points="653.458,571.367 653.458,557.461 
665.501,564.414 677.546,571.367 665.501,578.32 653.458,585.273 "/>
<polygon fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" points="653.458,543.553 653.458,529.646 
665.501,536.602 677.546,543.553 665.501,550.508 653.458,557.461 "/>

... and so on...
</svg>

... 等等
其他问题包括: 在网格中绘制线时是否有可能获得类似捕捉的效果? 在向量点附近?
有没有办法插入“后退/撤消”按钮并保存文件?

显示您可以在html代码中使用
标记。要操作svg,可以使用
javascript
。您可以像普通的
DOM
文档一样操作SVG图形。例如:

<html>
  <script>
    function colorChange()
    {
      var el = document.getElementById("mycircle");
      el.style.fill = "blue";
    }
  </script>
  <svg>
    <circle onClick="colorChange();" id="mycircle" cx="100" cy="50" r="40" stroke="black"
  stroke-width="2" fill="red"/>
  </svg>
</html>

函数colorChange()
{
var el=document.getElementById(“mycircle”);
el.style.fill=“蓝色”;
}

查看此示例以了解其实际作用。

您应该减少示例中的代码行数。太多了,没有任何额外的意义。非常感谢!现在我明白了机械师的意思!有办法切换颜色吗?对于svg中的许多小对象,我是否需要调用其中的任何一个来单击?对不起,我不明白你的意思。你能提供更多的细节吗?