From b2c34054d4473274a1ff38ef270ad461fd75ba8a Mon Sep 17 00:00:00 2001 From: JazzyNico Date: Tue, 31 Aug 2010 19:07:19 +0200 Subject: [PATCH] Extensions: * Number node cleanup. * New help tab in color>randomize. * Printing marks consistency fix. --- share/extensions/color_randomize.inx | 15 +++-- share/extensions/color_randomize.py | 4 ++ share/extensions/dots.inx | 6 +- share/extensions/dots.py | 90 +++++++++++++++------------- share/extensions/printing-marks.inx | 2 +- share/extensions/printing-marks.py | 8 +-- 6 files changed, 71 insertions(+), 54 deletions(-) diff --git a/share/extensions/color_randomize.inx b/share/extensions/color_randomize.inx index a6fdb7256..82691f0f4 100644 --- a/share/extensions/color_randomize.inx +++ b/share/extensions/color_randomize.inx @@ -5,9 +5,16 @@ coloreffect.py color_randomize.py simplestyle.py - true - true - true + + + true + true + true + + + <_param name="instructions" type="description" xml:space="preserve">Converts to HSL, randomizes hue and/or saturation and/or lightness and converts it back to RGB. + + all @@ -17,4 +24,4 @@ - \ No newline at end of file + diff --git a/share/extensions/color_randomize.py b/share/extensions/color_randomize.py index e27970e52..9ac9fb553 100644 --- a/share/extensions/color_randomize.py +++ b/share/extensions/color_randomize.py @@ -16,6 +16,10 @@ class C(coloreffect.ColorEffect): action="store", type="inkbool", dest="lightness", default=True, help="randomize lightness") + self.OptionParser.add_option("--tab", + action="store", type="string", + dest="tab", + help="The selected UI-tab when OK was pressed") def colmod(self,r,g,b): hsl = self.rgb_to_hsl(r/255.0, g/255.0, b/255.0) diff --git a/share/extensions/dots.inx b/share/extensions/dots.inx index 1eca17030..190418cac 100644 --- a/share/extensions/dots.inx +++ b/share/extensions/dots.inx @@ -6,15 +6,15 @@ inkex.py - 20 + 20px 10px 1 1 <_param name="instructions" type="description" xml:space="preserve">This extension replaces the selection's nodes with numbered dots according to the following options: - * Font size: size of the node number labels. - * Dot size: diameter of the dots placed at path nodes. + * Font size: size of the node number labels (20px, 12pt...). + * Dot size: diameter of the dots placed at path nodes (10px, 2mm...). * Starting dot number: first number in the sequence, assigned to the first node of the path. * Step: numbering step between two nodes. diff --git a/share/extensions/dots.py b/share/extensions/dots.py index eb4aabd84..c3d3671c4 100755 --- a/share/extensions/dots.py +++ b/share/extensions/dots.py @@ -22,9 +22,6 @@ class Dots(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) - self.OptionParser.add_option("--tab", - action="store", type="string", - dest="tab") self.OptionParser.add_option("-d", "--dotsize", action="store", type="string", dest="dotsize", default="10px", @@ -41,7 +38,20 @@ class Dots(inkex.Effect): action="store", type="int", dest="step", default="1", help="Numbering step between two nodes") - + self.OptionParser.add_option("--tab", + action="store", type="string", + dest="tab", + help="The selected UI-tab when OK was pressed") + + def effect(self): + selection = self.selected + if (selection): + for id, node in selection.iteritems(): + if node.tag == inkex.addNS('path','svg'): + self.addDot(node) + else: + inkex.errormsg("Please select an object.") + def separateLastAndFirst(self, p): # Separate the last and first dot if they are togheter lastDot = -1 @@ -62,47 +72,43 @@ class Dots(inkex.Effect): p[lastDot][1][-2] += x * inkex.unittouu(self.options.dotsize) p[lastDot][1][-1] += y * inkex.unittouu(self.options.dotsize) + def addDot(self, node): + self.group = inkex.etree.SubElement( node.getparent(), inkex.addNS('g','svg') ) + self.dotGroup = inkex.etree.SubElement( self.group, inkex.addNS('g','svg') ) + self.numGroup = inkex.etree.SubElement( self.group, inkex.addNS('g','svg') ) + + try: + t = node.get('transform') + self.group.set('transform', t) + except: + pass - def effect(self): - for id, node in self.selected.iteritems(): - if node.tag == inkex.addNS('path','svg'): - self.group = inkex.etree.SubElement( node.getparent(), inkex.addNS('g','svg') ) - self.dotGroup = inkex.etree.SubElement( self.group, inkex.addNS('g','svg') ) - self.numGroup = inkex.etree.SubElement( self.group, inkex.addNS('g','svg') ) - - try: - t = node.get('transform') - self.group.set('transform', t) - except: - pass - - style = simplestyle.formatStyle({ 'stroke': 'none', 'fill': '#000' }) - a = [] - p = simplepath.parsePath(node.get('d')) - - self.separateLastAndFirst(p) + style = simplestyle.formatStyle({ 'stroke': 'none', 'fill': '#000' }) + a = [] + p = simplepath.parsePath(node.get('d')) - num = self.options.start - for cmd,params in p: - if cmd != 'Z' and cmd != 'z': - dot_att = { - 'style': style, - 'r': str( inkex.unittouu(self.options.dotsize) / 2 ), - 'cx': str( params[-2] ), - 'cy': str( params[-1] ) - } - inkex.etree.SubElement( - self.dotGroup, - inkex.addNS('circle','svg'), - dot_att ) - self.addText( - self.numGroup, - params[-2] + ( inkex.unittouu(self.options.dotsize) / 2 ), - params[-1] - ( inkex.unittouu(self.options.dotsize) / 2 ), - num ) - num += self.options.step - node.getparent().remove( node ) + self.separateLastAndFirst(p) + num = self.options.start + for cmd,params in p: + if cmd != 'Z' and cmd != 'z': + dot_att = { + 'style': style, + 'r': str( inkex.unittouu(self.options.dotsize) / 2 ), + 'cx': str( params[-2] ), + 'cy': str( params[-1] ) + } + inkex.etree.SubElement( + self.dotGroup, + inkex.addNS('circle','svg'), + dot_att ) + self.addText( + self.numGroup, + params[-2] + ( inkex.unittouu(self.options.dotsize) / 2 ), + params[-1] - ( inkex.unittouu(self.options.dotsize) / 2 ), + num ) + num += self.options.step + node.getparent().remove( node ) def addText(self,node,x,y,text): new = inkex.etree.SubElement(node,inkex.addNS('text','svg')) diff --git a/share/extensions/printing-marks.inx b/share/extensions/printing-marks.inx index e652945d8..4447a275e 100644 --- a/share/extensions/printing-marks.inx +++ b/share/extensions/printing-marks.inx @@ -19,7 +19,7 @@ <_item value="canvas">Canvas <_item value="selection">Selection - + diff --git a/share/extensions/printing-marks.py b/share/extensions/printing-marks.py index 775f6b643..041025708 100644 --- a/share/extensions/printing-marks.py +++ b/share/extensions/printing-marks.py @@ -36,9 +36,6 @@ class Printing_Marks (inkex.Effect): def __init__(self): inkex.Effect.__init__(self) - self.OptionParser.add_option("--tab", - action="store", type="string", - dest="tab") self.OptionParser.add_option("--where", action="store", type="string", dest="where_to_crop", default=True, @@ -91,7 +88,10 @@ class Printing_Marks (inkex.Effect): action="store", type="float", dest="bleed_right", default=0, help="Bleed Right Size") - + self.OptionParser.add_option("--tab", + action="store", type="string", + dest="tab", + help="The selected UI-tab when OK was pressed") def draw_crop_line(self, x1, y1, x2, y2, name, parent): style = { 'stroke': '#000000', 'stroke-width': str(self.stroke_width), -- 2.30.2