将 GIMP 路径导出到 .svg 问题
我使用 GIMP 文件上的指南创建了一条只有直线的路径 - 没有曲线或任何东西。 但是,当我导出路径时,SVG 代码使用“C”曲线指示器来绘制路径。 所以部分代码看起来像这样:
<path id="Unnamed"
fill="none" stroke="black" stroke-width="1"
d="M 400.00,1230.00
C 400.00,1230.00 328.00,1230.00 328.00,1230.00
328.00,1230.00 328.00,962.00 328.00,962.00
...
Z"
</path>
我想去掉这个文件中导出的坐标并将它们用于一堆其他事情,处理“C”格式显然是一件微不足道的事情,但我“我想知道为什么它使用 C 而不是 L,如果 .svg 文件使用 L,我是否可以在真正复杂的路径上获得更快的加载时间。
I used the guides on a GIMP file to create a path which is just straight lines - no curves or anything. However, when I export the path, the SVG code uses "C" the curve indicator to draw the path. So part of the code looks like this:
<path id="Unnamed"
fill="none" stroke="black" stroke-width="1"
d="M 400.00,1230.00
C 400.00,1230.00 328.00,1230.00 328.00,1230.00
328.00,1230.00 328.00,962.00 328.00,962.00
...
Z"
</path>
I want to strip out the coordinates that have been exported in this file and use them for a bunch of other things, and its obviously a trivial matter to handle the "C" format, but I"m wondering why it used C and not L and if I can get the load time faster on really complex paths if the .svg file used L.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这与路径在 GIMP 中表示为贝塞尔曲线这一事实有关(正如已经正确猜测的那样)。
git.gnome 上的代码 gimpvectors-export.c
根据以下正确导出这些曲线
SVG 推荐。
因此,每当您最终在 GIMP 中使用您的路径创建多个控制点(您基本上一直这样做)时,您最终都会得到导出的结果。
It has something to do with the fact that paths are represented as bezier curves in GIMP (as already correctly guessed).
The code gimpvectors-export.c at git.gnome
exports these curves correctly according to the
SVG Recommendation.
So whenever you end up creating more than one control point in GIMP with your path (which you basically do all the time), you'll end up with the exported result.
我的猜测是,GIMP 只是将每个路径段视为贝塞尔曲线,因此也将它们导出到 SVG。 或者他们只是懒于实现某些路径的专门编码。 无论如何,我认为这些曲线在功能上等同于直线段。 所以它仍然是完全相同的信息。
至于加载时间,我认为这没有太大区别。 我认为,XML 和路径语法都必须进行解析,无论后者多一些还是少一些标记,都不会有太大区别。 但是,像往常一样:如果有疑问,请配置文件:-)
My guess is that GIMP just treats every path segment as a Bézier curve and therefore exports them to SVG as such as well. Or they simply were to lazy to implement specialized encoding of certain paths. In any event, how I see it those curves are functionally equivalent to your straight line segments. so it's still exactly the same information.
As for the load time, I think it doesn't make much of a difference. Both the XML and the path syntax have to be parsed, whether it's a few tokens more or less in the latter shouldn't make much of a difference, I think. However, as usual: If in doubt, profile :-)
如果你只有直线,那么我想在某些情况下它会有所不同,因为 lineto 命令只需要指定一个点,而 curvto 命令需要三个点。 这可能会使文件更大,因此可能会影响加载/解析时间。 虽然可能不会太多,除非你有大量的线路。
If you have only straight lines then I suppose it can make a difference in some cases, because a lineto command only needs to specify one point, while the curvto needs three. This can make the file larger, and thus may have an affect on loading/parsing time. Though probably not by very much unless you have a huge number of lines.