微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

什么是 svg.js 中的 Raphael.transformPath 模拟?

如何解决什么是 svg.js 中的 Raphael.transformPath 模拟?

Raphael 具有将一条路径转换为另一条路径的绝妙功能

 R.transformPath = function (path,transform) {
   return mapPath(path,toMatrix(path,transform));
 }

svg.js 有没有类似的功能

解决方法

要转换路径数组,您可以按照以下方式做一些事情:


const arr = path.array()

arr.map(segment => {
  // ... add code to get the x and y of all the points used
  // for a line it would be segment[1] and segment[2]

  const {x,y} = new SVG.Point(segment[1],segment[2]).transform(transform)
  return [segment[0],x,y]
})

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。