moved rounder to new category, added docs and hints
This commit is contained in:
parent
d048d39a62
commit
c7879f3daa
@ -13,11 +13,14 @@
|
|||||||
<param name="opacity" type="bool" gui-text="Round global opacity">false</param>
|
<param name="opacity" type="bool" gui-text="Round global opacity">false</param>
|
||||||
<param name="strokeopacity" type="bool" gui-text="Round stroke opacity">false</param>
|
<param name="strokeopacity" type="bool" gui-text="Round stroke opacity">false</param>
|
||||||
<param name="fillopacity" type="bool" gui-text="Round fill opacity">false</param>
|
<param name="fillopacity" type="bool" gui-text="Round fill opacity">false</param>
|
||||||
|
<spacer/>
|
||||||
|
<label>Please note: Rounder only applies to svg:path elements. You cannot use it for rectangle, circle, ellipsis, arc, polygon, line, polyline, etc.</label>
|
||||||
|
<label appearance="url">https://y.stadtfabrikanten.org/rounder</label>
|
||||||
<effect>
|
<effect>
|
||||||
<object-type>all</object-type>
|
<object-type>all</object-type>
|
||||||
<effects-menu>
|
<effects-menu>
|
||||||
<submenu name="FabLab Chemnitz">
|
<submenu name="FabLab Chemnitz">
|
||||||
<submenu name="Various" />
|
<submenu name="Modify existing Path(s)" />
|
||||||
</submenu>
|
</submenu>
|
||||||
</effects-menu>
|
</effects-menu>
|
||||||
</effect>
|
</effect>
|
||||||
|
@ -30,8 +30,8 @@ class svgRounder(inkex.EffectExtension):
|
|||||||
|
|
||||||
def add_arguments(self, pars):
|
def add_arguments(self, pars):
|
||||||
pars.add_argument("--precision", type=int, default=3, help="Precision")
|
pars.add_argument("--precision", type=int, default=3, help="Precision")
|
||||||
pars.add_argument("--ctrl", type=inkex.Boolean, default = False, help="Round node handles")
|
pars.add_argument("--ctrl", type=inkex.Boolean, default = False, help="Round element handles")
|
||||||
pars.add_argument("--along", type=inkex.Boolean, default = True, help="Move handles following node movement")
|
pars.add_argument("--along", type=inkex.Boolean, default = True, help="Move handles following element movement")
|
||||||
pars.add_argument("--half", type=inkex.Boolean, default = False, help="Allow round to half if nearest")
|
pars.add_argument("--half", type=inkex.Boolean, default = False, help="Allow round to half if nearest")
|
||||||
pars.add_argument("--paths", type=inkex.Boolean, default = True, help="Affect to paths")
|
pars.add_argument("--paths", type=inkex.Boolean, default = True, help="Affect to paths")
|
||||||
pars.add_argument("--widthheight", type=inkex.Boolean, default = False, help="Affect to width and height of objects")
|
pars.add_argument("--widthheight", type=inkex.Boolean, default = False, help="Affect to width and height of objects")
|
||||||
@ -55,9 +55,9 @@ class svgRounder(inkex.EffectExtension):
|
|||||||
y = self.roundFloat(p[1])
|
y = self.roundFloat(p[1])
|
||||||
return [float(x) - p[0], float(y) - p[1]]
|
return [float(x) - p[0], float(y) - p[1]]
|
||||||
|
|
||||||
def path_round_it(self,node):
|
def path_round_it(self,element):
|
||||||
if node.tag == inkex.addNS('path','svg'):
|
if element.tag == inkex.addNS('path','svg'):
|
||||||
d = node.get('d')
|
d = element.get('d')
|
||||||
p = CubicSuperPath(d)
|
p = CubicSuperPath(d)
|
||||||
for subpath in p:
|
for subpath in p:
|
||||||
for csp in subpath:
|
for csp in subpath:
|
||||||
@ -77,9 +77,9 @@ class svgRounder(inkex.EffectExtension):
|
|||||||
delta = self.roundit(csp[2])
|
delta = self.roundit(csp[2])
|
||||||
csp[2][0]+=delta[0]
|
csp[2][0]+=delta[0]
|
||||||
csp[2][1]+=delta[1]
|
csp[2][1]+=delta[1]
|
||||||
node.set('d',str(Path(p)))
|
element.set('d',str(Path(p)))
|
||||||
elif node.tag == inkex.addNS('g','svg'):
|
elif element.tag == inkex.addNS('g','svg'):
|
||||||
for e in node:
|
for e in element:
|
||||||
self.path_round_it(e)
|
self.path_round_it(e)
|
||||||
|
|
||||||
def roundStroke(self,matchobj):
|
def roundStroke(self,matchobj):
|
||||||
@ -92,69 +92,74 @@ class svgRounder(inkex.EffectExtension):
|
|||||||
return matchobj.group(1) + self.roundFloat(float( matchobj.group(2))) + matchobj.group(3);
|
return matchobj.group(1) + self.roundFloat(float( matchobj.group(2))) + matchobj.group(3);
|
||||||
|
|
||||||
|
|
||||||
def stroke_round_it(self, node):
|
def stroke_round_it(self, element):
|
||||||
if node.tag == inkex.addNS('g','svg'):
|
if element.tag == inkex.addNS('g','svg'):
|
||||||
for e in node:
|
for e in element:
|
||||||
self.stroke_round_it(e)
|
self.stroke_round_it(e)
|
||||||
else:
|
else:
|
||||||
style = node.get('style')
|
style = element.get('style')
|
||||||
if style:
|
if style:
|
||||||
style = re.sub('stroke-width:(.*?)(;|$)',self.roundStroke, style)
|
style = re.sub('stroke-width:(.*?)(;|$)',self.roundStroke, style)
|
||||||
node.set('style',style)
|
element.set('style',style)
|
||||||
def opacity_round_it(self, node, typeOpacity):
|
def opacity_round_it(self, element, typeOpacity):
|
||||||
if node.tag == inkex.addNS('g','svg'):
|
if element.tag == inkex.addNS('g','svg'):
|
||||||
for e in node:
|
for e in element:
|
||||||
self.opacity_round_it(e, typeOpacity)
|
self.opacity_round_it(e, typeOpacity)
|
||||||
else:
|
else:
|
||||||
style = node.get('style')
|
style = element.get('style')
|
||||||
if style:
|
if style:
|
||||||
style = re.sub('(^|;)(' + typeOpacity + ':)(.*?)(;|$)',self.roundOpacity, style)
|
style = re.sub('(^|;)(' + typeOpacity + ':)(.*?)(;|$)',self.roundOpacity, style)
|
||||||
node.set('style',style)
|
element.set('style',style)
|
||||||
|
|
||||||
def widthheight_round_it(self, node):
|
def widthheight_round_it(self, element):
|
||||||
if node.tag == inkex.addNS('g','svg'):
|
if element.tag == inkex.addNS('g','svg'):
|
||||||
for e in node:
|
for e in element:
|
||||||
self.widthheight_round_it(e)
|
self.widthheight_round_it(e)
|
||||||
else:
|
else:
|
||||||
width = node.get('width')
|
width = element.get('width')
|
||||||
if width:
|
if width:
|
||||||
width = re.sub('^(\-|)([0-9]+\.[0-9]+)(.*?)$',self.roundWHXY, width)
|
width = re.sub('^(\-|)([0-9]+\.[0-9]+)(.*?)$',self.roundWHXY, width)
|
||||||
node.set('width',width)
|
element.set('width',width)
|
||||||
height = node.get('height')
|
height = element.get('height')
|
||||||
if height:
|
if height:
|
||||||
height = re.sub('^(\-|)([0-9]+\.[0-9]+)(.*?)$',self.roundWHXY, height)
|
height = re.sub('^(\-|)([0-9]+\.[0-9]+)(.*?)$',self.roundWHXY, height)
|
||||||
node.set('height',height)
|
element.set('height',height)
|
||||||
|
|
||||||
def position_round_it(self, node):
|
def position_round_it(self, element):
|
||||||
if node.tag == inkex.addNS('g','svg'):
|
if element.tag == inkex.addNS('g','svg'):
|
||||||
for e in node:
|
for e in element:
|
||||||
self.position_round_it(e)
|
self.position_round_it(e)
|
||||||
else:
|
else:
|
||||||
x = node.get('x')
|
x = element.get('x')
|
||||||
if x:
|
if x:
|
||||||
x = re.sub('^(\-|)([0-9]+\.[0-9]+)(.*?)$',self.roundWHXY, x)
|
x = re.sub('^(\-|)([0-9]+\.[0-9]+)(.*?)$',self.roundWHXY, x)
|
||||||
node.set('x', x)
|
element.set('x', x)
|
||||||
y = node.get('y')
|
y = element.get('y')
|
||||||
if y:
|
if y:
|
||||||
y = re.sub('^(\-|)([0-9]+\.[0-9]+)(.*?)$',self.roundWHXY, y)
|
y = re.sub('^(\-|)([0-9]+\.[0-9]+)(.*?)$',self.roundWHXY, y)
|
||||||
node.set('y', y)
|
element.set('y', y)
|
||||||
|
|
||||||
def effect(self):
|
def effect(self):
|
||||||
for id, node in self.svg.selected.items():
|
|
||||||
|
if len(self.svg.selected) > 0:
|
||||||
|
for element in self.svg.selection.values():
|
||||||
if self.options.paths:
|
if self.options.paths:
|
||||||
self.path_round_it(node)
|
self.path_round_it(element)
|
||||||
if self.options.strokewidth:
|
if self.options.strokewidth:
|
||||||
self.stroke_round_it(node)
|
self.stroke_round_it(element)
|
||||||
if self.options.widthheight:
|
if self.options.widthheight:
|
||||||
self.widthheight_round_it(node)
|
self.widthheight_round_it(element)
|
||||||
if self.options.position:
|
if self.options.position:
|
||||||
self.position_round_it(node)
|
self.position_round_it(element)
|
||||||
if self.options.opacity:
|
if self.options.opacity:
|
||||||
self.opacity_round_it(node, "opacity")
|
self.opacity_round_it(element, "opacity")
|
||||||
if self.options.strokeopacity:
|
if self.options.strokeopacity:
|
||||||
self.opacity_round_it(node, "stroke-opacity")
|
self.opacity_round_it(element, "stroke-opacity")
|
||||||
if self.options.fillopacity:
|
if self.options.fillopacity:
|
||||||
self.opacity_round_it(node, "fill-opacity")
|
self.opacity_round_it(element, "fill-opacity")
|
||||||
|
else:
|
||||||
|
self.msg('Please select some paths first.')
|
||||||
|
return
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
svgRounder().run()
|
svgRounder().run()
|
Reference in New Issue
Block a user