应用所有变换矩阵 [英] apply all transform matrices

查看:119
本文介绍了应用所有变换矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种可能快速的方法来应用给定svg-graphic的所有变换矩阵。换句话说:算法应该删除所有变换属性,并将图形的所有坐标转换为绝对坐标。

I am looking for a possibly fast way to apply all transform matrices of a given svg-graphic. In other words: the algorithm should remove all "transform" attributes and transform all coordinates of the graphic to absolute coordinates.

他们的任何库是否能够做到这一点,或者是他们的任何SVGDomInterface方法都可以做到吗?

Is their any library that can do this, or is their any SVGDomInterface method that coulld do that?

:

如果我这样调用整合方法:

If I call the consolidate method like this:

$.each( svg.find( 'path' ), function( i ){
        this.transform.baseVal.consolidate();
});

没有任何反应,如果我这样称呼:

nothing happens, if i call it like this:

$.each( svg.find( 'path' ), function( i ){
        this.transform.animVal.consolidate();
});

我收到此错误:

< img src =https://i.stack.imgur.com/YP7cf.pngalt =error>

那么,我应该如何使用合并 方法,我应该在哪个元素上调用它?

So, how should i use the "consolidate" method, on which elements shall I call it?

问候
philipp

Greetings philipp

推荐答案

合并方法仅将矩阵列表缩减为单个矩阵。你在animVal示例中得到的错误是因为你不允许修改动画值(合并破坏性地修改变换列表)。

The consolidate method only reduces the list of matrices to a single matrix. And the error you get on the animVal example is because you are not allowed to modify the animated values (consolidate destructively modifies the transform list).

要回答你的问题,不要SVG DOM中没有现有的方法通过修改路径的值等来应用变换.Inkscape(以及Illustrator IIRC)中有一些选项用于应用这样的变换。

To answer your question, no there's no existing method in SVG DOM that applies the transforms by modifying the values of paths etc. There are options in Inkscape (and Illustrator too IIRC) for applying transforms like that.

如果您正在寻找可以执行此操作的库或实用程序,您可以尝试 SVG Cleaner

If you're looking for a library or utility that does this you can try SVG Cleaner.

这篇关于应用所有变换矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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