用于删除大多数"g transform"的命令行工具在SVG中? [英] Command-line tool to remove most "g transform" in SVG?

查看:132
本文介绍了用于删除大多数"g transform"的命令行工具在SVG中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个命令行工具可以删除大多数"g 从我的SVG文件中转换...",因此我可以看到 我的点/线/多边形的绝对"位置?

Is there a command-line tool to remove most "g transform..."s from my SVG files, so I can see the "absolute" location of my points/lines/polygons?

换句话说,有没有人实现矩阵 乘法技术在以下内容中进行了解释: 在Inkscape中平整SVG矩阵变换如何通过转换和矩阵获取SVG中元素的实际x/y位置作为命令行工具?

In other words, has anyone implemented the matrix multiplication technique explained in: Flattening SVG matrix transforms in Inkscape and How to get the actual x/y position of an element in SVG with transformations and matrices as a command-line tool?

SVG Cleaner似乎需要Qt,但似乎没有 命令行工具(另外,我无法编译)

SVG Cleaner appears to require Qt and does not appear to be a command-line tool (plus, I couldn't get it to compile)

推荐答案

不,没有人使用此工具.至少不是您或我能找到的.问题的一部分在于您的定义.您要求删除转换,

No, nobody has made this tool. At least, not that either you or I can find. Part of the problem is in your definition. You ask to remove the transforms,

[…],这样我就可以看到点/线/多边形的绝对"位置.

对于SVG元素和转换的子集,可以将转换烘焙到元素的属性中,但在一般情况下不起作用.例如,考虑以下简单情况:

For a subset of SVG elements and transforms it is possible to bake the transform into the element's attributes, but it can't work in the general case. For example, consider this simple case:

<svg xmlns="http://www.w3.org/2000/svg">
  <g transform="translate(-10,10) skewX(57) rotate(45) translate(17,17)">
    <rect fill="red" stroke="blue" width="20" height="30" />
  </g>
</svg>

无法修改<rect>元素的特定属性,以使其显示相同的结果.最好的办法是在<rect>元素上放置一个transform="…"属性,该属性表示总的全局变换.在SVG UA中,这相对容易实现,而在独立的命令行工具中则要稍微困难一些(但仍然可以实现).我会帮助您,但是我认为结果对您没有帮助,因为它们没有告诉您有关点的绝对位置的任何信息.

There is no possible way to modify the <rect> element's specific attributes so that it shows the same result. The best you can do is to put a transform="…" attribute on the <rect> element representing the total global transforms. This is relatively easy to do in an SVG UA, slightly harder to do in a standalone command-line tool (but still possible). I would help you do it, but I figure the results don't help you, as they don't tell you anything about the absolute location of the points.

您可能会想说不,我不能使用<rect>来做到这一点,但是我可以将<rect>转换为<polygon><path>并使用绝对坐标表示这些要点." 但是,你只说对了一半.如果您注意到由于倾斜而导致的视在笔画宽度变化,您会发现没有单个<polygon>可以准确表示倾斜的<rect>.

You might be tempted to say "No, I can't do it with a <rect>, but I could convert the <rect> into a <polygon> or a <path> and use absolute coordinates for those points." But you'd only be half correct. If you notice the varying apparent stroke width due to the skew, you will see that no single <polygon> can accurately represent the skewed <rect>.

通常,您唯一可以做的就是将所有<g>转换的总和烘烤到各个元素上,并意识到这种转换可能会严重影响内容的最终位置和外观.

In general, the only thing you can do is bake the sum of all <g> transforms onto the individual elements, and realize that such transforms may drastically affect the final location and appearance of the content.

这篇关于用于删除大多数"g transform"的命令行工具在SVG中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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