How to apply transform matrix to path coordinates in Raphael JS 2?

若如初见. 提交于 2019-12-05 05:03:26

Here's a jsFiddle that applies all the transforms for you: http://jsfiddle.net/ecmanaut/cFSjt/

It's possible that Raphael exposes some or all of the tools I've filled in myself, but if not, these do the trick nicely. If your needs cover more non-path elements too (like groups, rects, circles, ellipses, and so on), first convert them to path elements (using pathify, for instance).

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!