【问题标题】:What is the Raphael.transformPath analogue in svg.js?svg.js 中的 Raphael.transformPath 类似物是什么?
【发布时间】:2020-12-20 05:44:39
【问题描述】:

Raphael 有一个非常棒的功能,可以将一条路径转换为另一条路径:

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

svg.js中有类似的功能吗?

【问题讨论】:

  • 我在某个时候为此编写了代码,但它不在核心中。你要做的是,从路径中拉出 PathArray 并变换每个点

标签: raphael svg.js


【解决方案1】:

要转换路径数组,您可以按照这些思路做一些事情:


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]
})

【讨论】:

    猜你喜欢
    • 2017-04-14
    • 1970-01-01
    • 2019-10-16
    • 2021-11-20
    • 1970-01-01
    • 2012-10-01
    • 2020-04-29
    • 1970-01-01
    • 2013-02-06
    相关资源
    最近更新 更多