什么是 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]
})