如何在Raphael JS 2中将变换矩阵应用于路径坐标? [英] How to apply transform matrix to path coordinates in Raphael JS 2?

查看:120
本文介绍了如何在Raphael JS 2中将变换矩阵应用于路径坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Raphael JS 2中应用或烘焙几个路径的转换,然后我可以将它们组合成一个单独的路径。

I want to apply or 'bake' a transformation of several paths in Raphael JS 2, so that I can then combine them into one single path.

这是一个示例路径,我希望将transform属性应用于所有d坐标。

Here is an example path, where I would like the "transform" attribute to be applied to all the "d" coordinates.

<path style="" fill="#000000" stroke="none" d="M150,-265C182,-275,171,-220,180,-194L178,-194C181,-192,180,-185,181,-180C211,-169,282,-173,306,-166C308,-169,316,-171,315,-165C268,-157,225,-148,184,-137C188,-118,186,-96,190,-79L282,-131C289,-131,296,-135,297,-126C293,-118,271,-105,236,-80C190,-48,155,-20,125,-6C112,-15,115,-34,111,-51C121,-70,108,-107,107,-133C70,-132,-5,-126,0,-157C18,-170,39,-181,64,-191C75,-190,92,-181,100,-185C99,-198,95,-211,89,-225Z" transform="matrix(0.1389, 0, 0, 0.1389, 291.91, 235.465)" stroke-width="7.199999999999999">

我知道svg-edit框架可以将路径坐标转换为绝对位置,并删除变换矩阵在这个过程中。

I understand that the svg-edit framework can convert path coordinates to absolute positions, and remove the transform matrix in the process.

一些相关问题,我无法得到答案:

Some related questions, which I couldn't get my answer from:

  • Baking transforms into SVG Path Element commands
  • How to apply a transformation matrix?

推荐答案

在这个jsFiddle中可以找到部分解决方案: http://jsfiddle.net/X6YNm/1/

A partial solution can be found in this jsFiddle: http://jsfiddle.net/X6YNm/1/

//include whoa font, and raphael
paper = Raphael('holder');
var text = paper.print(300, 50, 'Foo', paper.getFont('whoa'), 50, 'baseline');
var path = new Array();
for ( var i = 0; i < text.length; i ++ ) {
   path[i] = paper.path(Raphael.pathToRelative(text[i].attr('path')));
   path[i].attr({ fill: 'red' }).translate(i * 250, 300);
}

它根据原始集合中的每个字符创建一个新路径。然而,小提琴并没有正确地区分角色。

It creates a new path, based on each character in the original set. However, the fiddle does not correctly space the characters.

关于raphael google小组的一些相关讨论:这里有一些谷歌小组讨论: https://groups.google.com/d/msg/raphaeljs/OP29oelR5Eg/zPi5m6rjsvIJ

Some related discussion on the raphael google group: Some google group discussion here: https://groups.google.com/d/msg/raphaeljs/OP29oelR5Eg/zPi5m6rjsvIJ

这篇关于如何在Raphael JS 2中将变换矩阵应用于路径坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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