【问题标题】:SVG Union of Shapes using javascript or d3 or inkscape script like Inkscape GUI doesSVG Union of Shapes 使用 javascript 或 d3 或像 Inkscape GUI 这样的 inkscape 脚本
【发布时间】:2012-10-26 11:11:33
【问题描述】:

我正在做一个简单的网站,我在其中放置了一些图形。现在我使用 Inkscape 绘制每个图表。我使用 Inkscape 在形状之间进行 UNION 操作。然后我保存新图表,再做一个并集,保存,等等。我需要重复大约 150 次 :(

我想知道我是否可以使用 javascript 或 D3 库来做到这一点。或者至少是让 Inkscape 自动完成的一种方式。

在完美的情况下,会有一个函数:

union(shapeA,shapeB): replace ShapeA and ShapeB by ShapeAunionB

你能给我关于这个问题的任何提示吗?有什么帮助吗?

【问题讨论】:

  • 可以编写 inkscape 脚本来做到这一点。请参阅tavmjong.free.fr/INKSCAPE/MANUAL/html/CommandLine.html 了解如何开始。
  • 谢谢埃里克! :) 我用 Python 编写了一个脚本,它调用 Inkscape 命令行,就像你建议的网站解释的那样。 command = "inkscape -f file.svg --verb=EditDeselect --select=shapeA --select=shapeB --verb=SelectionUnion --verb=FileSave --verb=FileClose" os.system(command)
  • 如果您将解决方案发布为我认为的答案,那就太好了。

标签: javascript svg union diagram


【解决方案1】:

有一个开源库:Javascript Clipper

Javascript Clipper 库对直线和多边形执行剪切和偏移。支持所有四种布尔裁剪操作 - 交集、并集、差异和异或。多边形可以是任何形状,包括自相交的多边形。

功能演示:http://jsclipper.sourceforge.net/5.0.2.2/main_demo.html

【讨论】:

    【解决方案2】:

    我用 Python 编写了一个脚本,它调用 Inkscape 命令行,就像 Erik Dahlström 建议的网站所解释的那样。

    command = "inkscape -f file.svg --verb=EditDeselect --select=shapeA --select=shapeB --verb=SelectionUnion --verb=FileSave --verb=FileClose" os.system(command)
    

    【讨论】:

      猜你喜欢
      • 2022-10-15
      • 1970-01-01
      • 2014-10-17
      • 1970-01-01
      • 2021-10-09
      • 2011-11-11
      • 1970-01-01
      • 1970-01-01
      • 2019-06-07
      相关资源
      最近更新 更多