Updated offset paths extension
This commit is contained in:
parent
34de5b50fe
commit
cc61295afa
73
extensions/fablabchemnitz/offset_paths.inx
Normal file
73
extensions/fablabchemnitz/offset_paths.inx
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||
<name>Offset Paths</name>
|
||||
<id>fablabchemnitz.de.offset_paths</id>
|
||||
<param name="tab" type="notebook">
|
||||
<page name="tab_settings" gui-text="Settings">
|
||||
<param name="unit" type="optiongroup" appearance="combo" gui-text="Unit">
|
||||
<option value="mm">mm</option>
|
||||
<option value="cm">cm</option>
|
||||
<option value="in">in</option>
|
||||
<option value="pt">pt</option>
|
||||
<option value="px">px</option>
|
||||
<option value="pc">pc</option>
|
||||
</param>
|
||||
<param name="offset_count" type="int" min="1" max="100000" gui-text="Number of offset paths">1</param>
|
||||
<param name="init_offset" type="float" precision="4" min="-1000" max="+1000" gui-text="Initial offset from original path">1.0000</param>
|
||||
<param name="offset" type="float" precision="4" min="-1000" max="+1000" gui-text="Offset between two paths">1.0000</param>
|
||||
<param name="offset_increase" type="float" precision="4" min="-1000" max="+1000" gui-text="Offset increase per iteration">0.0000</param>
|
||||
<param name="miterlimit" type="float" min="0.0" max="1000" gui-text="Miter limit">3.0</param>
|
||||
<param name="clipperscale" type="int" min="2" max="65.536" gui-text="Scaling factor" gui-description="Should be a multiplicator of 2, like 2^4=16 or 2^10=1024. The higher the scale factor the higher the quality.">1024</param>
|
||||
<param name="jointype" appearance="combo" type="optiongroup" default="2" gui-text="Join type">
|
||||
<option value="0">Square</option>
|
||||
<option value="1">Round</option>
|
||||
<option value="2">Miter</option>
|
||||
</param>
|
||||
<param name="endtype" appearance="combo" type="optiongroup" default="3" gui-text="End type">
|
||||
<option value="0">Closed Polygon</option>
|
||||
<option value="1">Closed Line</option>
|
||||
<option value="2">Open Butt</option>
|
||||
<option value="3">Open Square</option>
|
||||
<option value="4">Open Round</option>
|
||||
</param>
|
||||
<param name="copy_org" type="bool" gui-text="Keep original path" gui-description="If enabled, keeps original path as a copy">false</param>
|
||||
</page>
|
||||
<page name="tab_about" gui-text="About">
|
||||
<label appearance="header">Offset Paths</label>
|
||||
<label>Create offset for open or closed paths. Python library 'pyclipper' needs to be installed. Use 'Flatten Bezier' extension in advance of this plugin.</label>
|
||||
<label>2020 - 2021 / written by Mario Voigt (Stadtfabrikanten e.V. / FabLab Chemnitz)</label>
|
||||
<spacer/>
|
||||
<label appearance="header">Online Documentation</label>
|
||||
<label appearance="url">https://y.stadtfabrikanten.org/offsetpaths</label>
|
||||
<spacer/>
|
||||
<label appearance="header">Contributing</label>
|
||||
<label appearance="url">https://gitea.fablabchemnitz.de/MarioVoigt/mightyscape-1.X</label>
|
||||
<label appearance="url">mailto:mario.voigt@stadtfabrikanten.org</label>
|
||||
<spacer/>
|
||||
<label appearance="header">MightyScape Extension Collection</label>
|
||||
<label>This piece of software is part of the MightyScape for Inkscape Extension Collection and is licensed under GNU GPL v3</label>
|
||||
<label appearance="url">https://y.stadtfabrikanten.org/mightyscape-overview</label>
|
||||
</page>
|
||||
<page name="tab_donate" gui-text="Donate">
|
||||
<label appearance="header">Coffee + Pizza</label>
|
||||
<label>We are the Stadtfabrikanten, running the FabLab Chemnitz since 2016. A FabLab is an open workshop that gives people access to machines and digital tools like 3D printers, laser cutters and CNC milling machines.</label>
|
||||
<spacer/>
|
||||
<label>You like our work and want to support us? You can donate to our non-profit organization by different ways:</label>
|
||||
<label appearance="url">https://y.stadtfabrikanten.org/donate</label>
|
||||
<spacer/>
|
||||
<label>Thanks for using our extension and helping us!</label>
|
||||
<image>000_about_fablabchemnitz.svg</image>
|
||||
</page>
|
||||
</param>
|
||||
<effect>
|
||||
<object-type>all</object-type>
|
||||
<effects-menu>
|
||||
<submenu name="FabLab Chemnitz">
|
||||
<submenu name="Shape/Pattern from existing Path(s)"/>
|
||||
</submenu>
|
||||
</effects-menu>
|
||||
</effect>
|
||||
<script>
|
||||
<command location="inx" interpreter="python">offset_paths.py</command>
|
||||
</script>
|
||||
</inkscape-extension>
|
@ -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()
|
@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||
<name>Ofsplot (Offset Paths)</name>
|
||||
<id>fablabchemnitz.de.ofsplot</id>
|
||||
<param name="unit" type="optiongroup" appearance="combo" gui-text="Unit">
|
||||
<option value="mm">mm</option>
|
||||
<option value="cm">cm</option>
|
||||
<option value="in">in</option>
|
||||
<option value="pt">pt</option>
|
||||
<option value="px">px</option>
|
||||
<option value="pc">pc</option>
|
||||
</param>
|
||||
<param name="offset_count" type="int" min="1" max="100000" gui-text="Number of offset paths:">1</param>
|
||||
<param name="offset" type="float" precision="4" min="-1000" max="+1000" gui-text="Offset between two paths:">1.0000</param>
|
||||
<param name="init_offset" type="float" precision="4" min="-1000" max="+1000" gui-text="Initial offset from original path:">1.0000</param>
|
||||
<param name="copy_org" type="bool" gui-text="Copy original path (=keep it)">false</param>
|
||||
<param name="offset_increase" type="float" precision="4" min="-1000" max="+1000" gui-text="Offset increase per iteration:">0.0000</param>
|
||||
<param name="miterlimit" type="float" min="0.0" max="1000" gui-text="Miter limit">3.0</param>
|
||||
<param name="clipperscale" type="float" min="0.0" max="9999.0" gui-text="Scaling factor">1024.0</param>
|
||||
<param name="jointype" appearance="combo" type="optiongroup" default="2" gui-text="Join type">
|
||||
<option value="0">Square</option>
|
||||
<option value="1">Round</option>
|
||||
<option value="2">Miter</option>
|
||||
</param>
|
||||
<param name="endtype" appearance="combo" type="optiongroup" default="3" gui-text="End type">
|
||||
<option value="0">Closed Polygon</option>
|
||||
<option value="1">Closed Line</option>
|
||||
<option value="2">Open Butt</option>
|
||||
<option value="3">Open Square</option>
|
||||
<option value="4">Open Round</option>
|
||||
</param>
|
||||
<param name="settingsHelp" type="description">Python library pyclipper needs to be installed. Use Flatten Bezier plugin in advance of this plugin.</param>
|
||||
<effect>
|
||||
<object-type>all</object-type>
|
||||
<effects-menu>
|
||||
<submenu name="FabLab Chemnitz">
|
||||
<submenu name="Shape/Pattern from existing Path(s)"/>
|
||||
</submenu>
|
||||
</effects-menu>
|
||||
</effect>
|
||||
<script>
|
||||
<command location="inx" interpreter="python">ofsplot.py</command>
|
||||
</script>
|
||||
</inkscape-extension>
|
Reference in New Issue
Block a user