Code

Extensions:
authorJazzyNico <nicoduf@yahoo.fr>
Tue, 31 Aug 2010 17:07:19 +0000 (19:07 +0200)
committerJazzyNico <nicoduf@yahoo.fr>
Tue, 31 Aug 2010 17:07:19 +0000 (19:07 +0200)
* Number node cleanup.
* New help tab in color>randomize.
* Printing marks consistency fix.

share/extensions/color_randomize.inx
share/extensions/color_randomize.py
share/extensions/dots.inx
share/extensions/dots.py
share/extensions/printing-marks.inx
share/extensions/printing-marks.py

index a6fdb72560ba9d5fe70c40c30ad772432d615ed4..82691f0f46c432446035695c9118a028b54111d8 100644 (file)
@@ -5,9 +5,16 @@
        <dependency type="executable" location="extensions">coloreffect.py</dependency>
        <dependency type="executable" location="extensions">color_randomize.py</dependency>
        <dependency type="executable" location="extensions">simplestyle.py</dependency>
-       <param name="hue" type="boolean" _gui-text="Hue">true</param>
-       <param name="saturation" type="boolean" _gui-text="Saturation">true</param>
-       <param name="lightness" type="boolean" _gui-text="Lightness">true</param>
+       <param name="tab" type="notebook">
+        <page name="Options" _gui-text="Options">
+               <param name="hue" type="boolean" _gui-text="Hue">true</param>
+               <param name="saturation" type="boolean" _gui-text="Saturation">true</param>
+               <param name="lightness" type="boolean" _gui-text="Lightness">true</param>
+        </page>
+        <page name="Help" _gui-text="Help">
+            <_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.</_param>
+        </page>
+    </param>    
        <effect>
                <object-type>all</object-type>
                <effects-menu>
@@ -17,4 +24,4 @@
        <script>
                <command reldir="extensions" interpreter="python">color_randomize.py</command>
        </script>
-</inkscape-extension>
\ No newline at end of file
+</inkscape-extension>
index e27970e523e8128d0f2cc16130ae9048b5681562..9ac9fb55349786dd27879baca15ec13d16bce71a 100644 (file)
@@ -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)
index 1eca17030b98ef82347d72422e5180ae926ee0fc..190418cac3deca4050a7ced9a499fbbd6bc29abf 100644 (file)
@@ -6,15 +6,15 @@
        <dependency type="executable" location="extensions">inkex.py</dependency>
        <param name="tab" type="notebook">
         <page name="Options" _gui-text="Options">
-               <param name="fontsize" type="string" _gui-text="Font size:">20</param>
+               <param name="fontsize" type="string" _gui-text="Font size:">20px</param>
                <param name="dotsize" type="string" _gui-text="Dot size:">10px</param>
             <param name="start" type="int" min="0" max="1000" _gui-text="Starting dot number:">1</param>
             <param name="step" type="int" min="0" max="1000" _gui-text="Step:">1</param>
         </page>
         <page name="Help" _gui-text="Help">
             <_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.</_param>
         </page>
index eb4aabd84c3ca2393c4ce654eabcfdfa8da6ef4f..c3d3671c46151a8249e1d5736e4844744680fe62 100755 (executable)
@@ -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'))
index e652945d8073ef2504b9e1512638da4a0ce49b9d..4447a275ea14915215a8bcd9d3a73b1921c47ad6 100644 (file)
@@ -19,7 +19,7 @@
            <_item value="canvas">Canvas</_item>
            <_item value="selection">Selection</_item>
       </param>
-      <param name="unit" _gui-text="Unit" type="optiongroup" appearance="minimal">
+      <param name="unit" _gui-text="Unit:" type="optiongroup" appearance="minimal">
            <option value="px">px</option>
                <option value="pt">pt</option>
                <option value="in">in</option>
index 775f6b6431f39e1efae7f2739f9ff95511bb9bc1..041025708bfd8dbdcd94eb9f42b59041f85ada1a 100644 (file)
@@ -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),