脚本<路径>SVG 中的数据(读取和修改) [英] Scripting &lt;path&gt; data in SVG (reading and modifying)

查看:26
本文介绍了脚本<路径>SVG 中的数据(读取和修改)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

真的有人能帮我吗?我一直在寻找为我的 SVG 运行脚本的方法.但是我得到的所有东西都不匹配!它没有包含足够的信息,为什么他使用这组代码.例如,一个使用 event.target,另一个使用 event.getTarget(),另一个使用 event.target.firstchild.data.有谁能帮帮我吗?

Can anyone really really help me, please? I've been searching for ways to run scripts for my SVG. But all the things i got doesn't match up! And it doesn't contain enough information why he used that set of codes. For example, one used event.target, another had event.getTarget(), and another had event.target.firstchild.data. Can anyone help me, please?

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  <path d="M150 0 L75 200 L225 200 Z" />
</svg>

是路径 svg 的一个例子吧?我需要的是获取这些坐标,可能将其放入一个变量中,并将其用作另一个 svg 的坐标.那我该怎么做呢?另一件事是如何通过在界面中输入数字来更改这些坐标.

is an example of a path svg right? What i need is to get those coordinates, probably put it in a variable, and use it as coordinates for another svg. So how can i do that? Another thing is how can i change those coordinates by entering numbers in an interface.

所以我试图寻找答案,但就像我说的,我没有找到我需要的信息,或者我只是不明白它向我展示了什么.

So i tried to look for answers, but like i said, i didn't find the info i needed or maybe i just didn't i understand what it showed me.

推荐答案

听起来您可能有四个问题:

It sounds like you may have four questions:

  1. 如何在 SVG 文件中嵌入脚本?
  2. 如何在 SVG 文件中运行脚本?
  3. 如何从脚本访问 元素的数据?
  4. 如何操作脚本中 元素的数据?
  1. How do I embed script inside an SVG file?
  2. How do I run script inside an SVG file?
  3. How do I access data for a <path> element from script?
  4. How can I manipulate data for a <path> element from script?

让我们一次解决一个问题:

Let's tackle them one at a time:

SVG 规范中所述,您可以将

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