From cc61295afa301666b8485262935267d38a8c6ca9 Mon Sep 17 00:00:00 2001 From: leyghisbb Date: Thu, 22 Apr 2021 15:12:18 +0200 Subject: [PATCH] Updated offset paths extension --- extensions/fablabchemnitz/offset_paths.inx | 73 +++++++++++++++++++ .../{ofsplot.py => offset_paths.py} | 22 ++++-- extensions/fablabchemnitz/ofsplot.inx | 44 ----------- 3 files changed, 90 insertions(+), 49 deletions(-) create mode 100644 extensions/fablabchemnitz/offset_paths.inx rename extensions/fablabchemnitz/{ofsplot.py => offset_paths.py} (87%) delete mode 100644 extensions/fablabchemnitz/ofsplot.inx diff --git a/extensions/fablabchemnitz/offset_paths.inx b/extensions/fablabchemnitz/offset_paths.inx new file mode 100644 index 00000000..b5f60355 --- /dev/null +++ b/extensions/fablabchemnitz/offset_paths.inx @@ -0,0 +1,73 @@ + + + Offset Paths + fablabchemnitz.de.offset_paths + + + + + + + + + + + 1 + 1.0000 + 1.0000 + 0.0000 + 3.0 + 1024 + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + 000_about_fablabchemnitz.svg + + + + all + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz/ofsplot.py b/extensions/fablabchemnitz/offset_paths.py similarity index 87% rename from extensions/fablabchemnitz/ofsplot.py rename to extensions/fablabchemnitz/offset_paths.py index 3a73d1a0..5aa59ea8 100644 --- a/extensions/fablabchemnitz/ofsplot.py +++ b/extensions/fablabchemnitz/offset_paths.py @@ -1,14 +1,26 @@ #!/usr/bin/env python3 +""" +Based on +- https://github.com/TimeTravel-0/ofsplot + +Author: Mario Voigt / FabLab Chemnitz +Mail: mario.voigt@stadtfabrikanten.org +Last Patch: 22.04.2021 +License: GNU GPL v3 + +""" + import inkex import math from inkex.paths import CubicSuperPath import re import pyclipper -class ofsplot(inkex.EffectExtension): +class OffsetPaths(inkex.EffectExtension): def add_arguments(self, pars): + pars.add_argument('--tab') pars.add_argument('--unit') pars.add_argument("--offset_count", type=int, default=1, help="Number of offset paths") pars.add_argument("--offset", type=float, default=1.000, help="Offset amount") @@ -18,10 +30,10 @@ class ofsplot(inkex.EffectExtension): pars.add_argument("--jointype", default="2", help="Join type") pars.add_argument("--endtype", default="3", help="End type") pars.add_argument("--miterlimit", type=float, default=3.0, help="Miter limit") - pars.add_argument("--clipperscale", type=float, default=1024.0, help="Scaling factor") + pars.add_argument("--clipperscale", type=int, default=1024, help="Scaling factor. Should be a multiplicator of 2, like 2^4=16 or 2^10=1024. The higher the scale factor the higher the quality.") def effect(self): - unit_factor = 1.0 / self.svg.uutounit(1.0,self.options.unit) + unit_factor = 1.0 / self.svg.uutounit(1.0, self.options.unit) paths = self.svg.selection.filter(inkex.PathElement).values() count = sum(1 for path in paths) paths = self.svg.selection.filter(inkex.PathElement).values() #we need to call this twice because the sum function consumes the generator @@ -95,7 +107,7 @@ class ofsplot(inkex.EffectExtension): for sub in p: new.append(sub) - path.set('d',CubicSuperPath(new)) + path.set('d', CubicSuperPath(new)) if __name__ == '__main__': - ofsplot().run() + OffsetPaths().run() \ No newline at end of file diff --git a/extensions/fablabchemnitz/ofsplot.inx b/extensions/fablabchemnitz/ofsplot.inx deleted file mode 100644 index c85ec1ae..00000000 --- a/extensions/fablabchemnitz/ofsplot.inx +++ /dev/null @@ -1,44 +0,0 @@ - - - Ofsplot (Offset Paths) - fablabchemnitz.de.ofsplot - - - - - - - - - 1 - 1.0000 - 1.0000 - false - 0.0000 - 3.0 - 1024.0 - - - - - - - - - - - - - Python library pyclipper needs to be installed. Use Flatten Bezier plugin in advance of this plugin. - - all - - - - - - - - \ No newline at end of file