summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3454b8d)
raw | patch | inline | side by side (parent: 3454b8d)
author | aurium <aurium@users.sourceforge.net> | |
Thu, 9 Apr 2009 15:02:04 +0000 (15:02 +0000) | ||
committer | aurium <aurium@users.sourceforge.net> | |
Thu, 9 Apr 2009 15:02:04 +0000 (15:02 +0000) |
share/extensions/Makefile.am | patch | blob | history | |
share/extensions/foldable-box.inx | [deleted file] | patch | blob | history |
share/extensions/foldable-box.py | [deleted file] | patch | blob | history |
share/extensions/foldablebox.inx | [new file with mode: 0644] | patch | blob |
share/extensions/foldablebox.py | [new file with mode: 0755] | patch | blob |
share/extensions/test/foldablebox.test.py | [new file with mode: 0755] | patch | blob |
share/extensions/test/run-all-extension-tests | [new file with mode: 0755] | patch | blob |
index 7fac49c5c78e192918e560052271577088b3cb5e..e168082d8f24c2d50716695e9373fd2d88af36bc 100644 (file)
ffgeom.py\
fig2dev-ext.py \
flatten.py \
- foldable-box.py \
+ foldablebox.py \
fractalize.py \
funcplot.py \
gears.py\
extrude.inx \
fig_input.inx \
flatten.inx \
- foldable-box.inx \
+ foldablebox.inx \
fractalize.inx \
funcplot.inx \
gears.inx\
diff --git a/share/extensions/foldable-box.inx b/share/extensions/foldable-box.inx
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
- <_name>Foldable Box</_name>
- <id>org.inkscape.render.foldable-box</id>
- <dependency type="executable" location="extensions">foldable-box.py</dependency>
- <dependency type="executable" location="extensions">inkex.py</dependency>
- <param name="width" type="float" min="0.1" max="1000.0" _gui-text="Width">10.0</param>
- <param name="height" type="float" min="0.1" max="1000.0" _gui-text="Height">15.0</param>
- <param name="depth" type="float" min="0.1" max="1000.0" _gui-text="Depth">3.0</param>
- <param name="paper-thickness" type="float" min="0.0" max="100.0" _gui-text="Paper Thickness">0.01</param>
- <param name="tab-proportion" type="float" min="0.1" max="1.0" _gui-text="Tab Proportion">0.6</param>
- <param name="unit" type="enum" _gui-text="Unit">
- <item>px</item>
- <item>pt</item>
- <item>in</item>
- <item>cm</item>
- <item>mm</item>
- </param>
- <param name="guide-line" type="boolean" _gui-text="Add Guide Lines">true</param>
- <effect>
- <object-type>all</object-type>
- <effects-menu>
- <submenu _name="Render"/>
- </effects-menu>
- </effect>
- <script>
- <command reldir="extensions" interpreter="python">foldable-box.py</command>
- </script>
-</inkscape-extension>
diff --git a/share/extensions/foldable-box.py b/share/extensions/foldable-box.py
+++ /dev/null
@@ -1,265 +0,0 @@
-#! /usr/bin/env python
-'''
-Copyright (C) 2009 Aurelio A. Heckert <aurium (a) gmail dot com>
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-'''
-
-__version__ = "0.2"
-
-import inkex, simplestyle
-from math import *
-from simplepath import formatPath
-
-class FoldableBox(inkex.Effect):
-
- def __init__(self):
- inkex.Effect.__init__(self)
- self.OptionParser.add_option("-x", "--width",
- action="store", type="float",
- dest="width", default=10.0,
- help="The Box Width - in the X dimension")
- self.OptionParser.add_option("-y", "--height",
- action="store", type="float",
- dest="height", default=15.0,
- help="The Box Height - in the Y dimension")
- self.OptionParser.add_option("-z", "--depth",
- action="store", type="float",
- dest="depth", default=3.0,
- help="The Box Depth - in the Z dimension")
- self.OptionParser.add_option("-u", "--unit",
- action="store", type="string",
- dest="unit", default="cm",
- help="The unit of the box dimensions")
- self.OptionParser.add_option("-p", "--paper-thickness",
- action="store", type="float",
- dest="thickness", default=0.01,
- help="Paper Thickness - sometimes that is important")
- self.OptionParser.add_option("-t", "--tab-proportion",
- action="store", type="float",
- dest="tabProportion", default=0.6,
- help="Inner tab propotion for upper tab")
- self.OptionParser.add_option("-g", "--guide-line",
- action="store", type="inkbool",
- dest="guideLine", default=True,
- help="Add guide lines to help the drawing limits")
-
- def effect(self):
-
- docW = inkex.unittouu(self.document.getroot().get('width'))
- docH = inkex.unittouu(self.document.getroot().get('height'))
-
- boxW = inkex.unittouu( str(self.options.width) + self.options.unit )
- boxH = inkex.unittouu( str(self.options.height) + self.options.unit )
- boxD = inkex.unittouu( str(self.options.depth) + self.options.unit )
- tabProp = self.options.tabProportion
- tabH = boxD * tabProp
-
- box_id = self.uniqueId('box')
- g = inkex.etree.SubElement(self.current_layer, 'g', {'id':box_id})
-
- line_style = simplestyle.formatStyle({ 'stroke': '#000000', 'fill': 'none' })
-
- #self.createGuide( 0, docH, 0 );
-
- # Inner Close Tab
- line_path = [
- [ 'M', [ boxW-(tabH*0.7), 0 ] ],
- [ 'C', [ boxW-(tabH*0.25), 0, boxW, tabH*0.3, boxW, tabH*0.9 ] ],
- [ 'L', [ boxW, tabH ] ],
- [ 'L', [ 0, tabH ] ],
- [ 'L', [ 0, tabH*0.9 ] ],
- [ 'C', [ 0, tabH*0.3, tabH*0.25, 0, tabH*0.7, 0 ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-inner-close-tab', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- lower_pos = boxD+tabH
- left_pos = 0
-
- #self.createGuide( 0, docH-tabH, 0 );
-
- # Upper Close Tab
- line_path = [
- [ 'M', [ left_pos, tabH ] ],
- [ 'L', [ left_pos + boxW, tabH ] ],
- [ 'L', [ left_pos + boxW, lower_pos ] ],
- [ 'L', [ left_pos + 0, lower_pos ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-upper-close-tab', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- left_pos += boxW
-
- # Upper Right Tab
- sideTabH = lower_pos - (boxW/2)
- if sideTabH < tabH: sideTabH = tabH
- line_path = [
- [ 'M', [ left_pos, sideTabH ] ],
- [ 'L', [ left_pos + (boxD*0.8), sideTabH ] ],
- [ 'L', [ left_pos + boxD, ((lower_pos*3)-sideTabH)/3 ] ],
- [ 'L', [ left_pos + boxD, lower_pos ] ],
- [ 'L', [ left_pos + 0, lower_pos ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-upper-right-tab', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- left_pos += boxW + boxD
-
- # Upper Left Tab
- line_path = [
- [ 'M', [ left_pos + boxD, sideTabH ] ],
- [ 'L', [ left_pos + (boxD*0.2), sideTabH ] ],
- [ 'L', [ left_pos, ((lower_pos*3)-sideTabH)/3 ] ],
- [ 'L', [ left_pos, lower_pos ] ],
- [ 'L', [ left_pos + boxD, lower_pos ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-upper-left-tab', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- left_pos = 0
-
- #self.createGuide( 0, docH-tabH-boxD, 0 );
-
- # Right Tab
- line_path = [
- [ 'M', [ left_pos, lower_pos ] ],
- [ 'L', [ left_pos - (boxD/2), lower_pos + (boxD/4) ] ],
- [ 'L', [ left_pos - (boxD/2), lower_pos + boxH - (boxD/4) ] ],
- [ 'L', [ left_pos, lower_pos + boxH ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-left-tab', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- # Front
- line_path = [
- [ 'M', [ left_pos, lower_pos ] ],
- [ 'L', [ left_pos + boxW, lower_pos ] ],
- [ 'L', [ left_pos + boxW, lower_pos + boxH ] ],
- [ 'L', [ left_pos, lower_pos + boxH ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-front', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- left_pos += boxW
-
- # Right
- line_path = [
- [ 'M', [ left_pos, lower_pos ] ],
- [ 'L', [ left_pos + boxD, lower_pos ] ],
- [ 'L', [ left_pos + boxD, lower_pos + boxH ] ],
- [ 'L', [ left_pos, lower_pos + boxH ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-right', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- left_pos += boxD
-
- # Back
- line_path = [
- [ 'M', [ left_pos, lower_pos ] ],
- [ 'L', [ left_pos + boxW, lower_pos ] ],
- [ 'L', [ left_pos + boxW, lower_pos + boxH ] ],
- [ 'L', [ left_pos, lower_pos + boxH ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-back', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- left_pos += boxW
-
- # Left
- line_path = [
- [ 'M', [ left_pos, lower_pos ] ],
- [ 'L', [ left_pos + boxD, lower_pos ] ],
- [ 'L', [ left_pos + boxD, lower_pos + boxH ] ],
- [ 'L', [ left_pos, lower_pos + boxH ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-left', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- lower_pos += boxH
- left_pos = 0
- bTab = lower_pos + boxD
- if bTab > boxW / 2.5: bTab = boxW / 2.5
-
- # Bottom Front Tab
- line_path = [
- [ 'M', [ left_pos, lower_pos ] ],
- [ 'L', [ left_pos, lower_pos + (boxD/2) ] ],
- [ 'L', [ left_pos + boxW, lower_pos + (boxD/2) ] ],
- [ 'L', [ left_pos + boxW, lower_pos ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-bottom-front-tab', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- left_pos += boxW
-
- # Bottom Right Tab
- line_path = [
- [ 'M', [ left_pos, lower_pos ] ],
- [ 'L', [ left_pos, lower_pos + bTab ] ],
- [ 'L', [ left_pos + boxD, lower_pos + bTab ] ],
- [ 'L', [ left_pos + boxD, lower_pos ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-bottom-right-tab', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- left_pos += boxD
-
- # Bottom Back Tab
- line_path = [
- [ 'M', [ left_pos, lower_pos ] ],
- [ 'L', [ left_pos, lower_pos + (boxD/2) ] ],
- [ 'L', [ left_pos + boxW, lower_pos + (boxD/2) ] ],
- [ 'L', [ left_pos + boxW, lower_pos ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-bottom-back-tab', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- left_pos += boxW
-
- # Bottom Left Tab
- line_path = [
- [ 'M', [ left_pos, lower_pos ] ],
- [ 'L', [ left_pos, lower_pos + bTab ] ],
- [ 'L', [ left_pos + boxD, lower_pos + bTab ] ],
- [ 'L', [ left_pos + boxD, lower_pos ] ],
- [ 'Z', [] ]
- ]
- line_atts = { 'style':line_style, 'id':box_id+'-bottom-left-tab', 'd':formatPath(line_path) }
- inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
-
- left_pos += boxD
- lower_pos += bTab
-
- g.set( 'transform', 'translate(%f,%f)' % ( (docW-left_pos)/2, (docH-lower_pos)/2 ) )
-
-if __name__ == '__main__':
- e = FoldableBox()
- e.affect()
-
-# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
diff --git a/share/extensions/foldablebox.inx b/share/extensions/foldablebox.inx
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>Foldable Box</_name>
+ <id>org.inkscape.render.foldable-box</id>
+ <dependency type="executable" location="extensions">foldablebox.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <param name="width" type="float" min="0.1" max="1000.0" _gui-text="Width">10.0</param>
+ <param name="height" type="float" min="0.1" max="1000.0" _gui-text="Height">15.0</param>
+ <param name="depth" type="float" min="0.1" max="1000.0" _gui-text="Depth">3.0</param>
+ <param name="paper-thickness" type="float" min="0.0" max="100.0" _gui-text="Paper Thickness">0.01</param>
+ <param name="tab-proportion" type="float" min="0.1" max="1.0" _gui-text="Tab Proportion">0.6</param>
+ <param name="unit" type="enum" _gui-text="Unit">
+ <item>px</item>
+ <item>pt</item>
+ <item>in</item>
+ <item>cm</item>
+ <item>mm</item>
+ </param>
+ <param name="guide-line" type="boolean" _gui-text="Add Guide Lines">true</param>
+ <effect>
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Render"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">foldablebox.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/foldablebox.py b/share/extensions/foldablebox.py
--- /dev/null
@@ -0,0 +1,265 @@
+#! /usr/bin/env python
+'''
+Copyright (C) 2009 Aurelio A. Heckert <aurium (a) gmail dot com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+'''
+
+__version__ = "0.2"
+
+import inkex, simplestyle
+from math import *
+from simplepath import formatPath
+
+class FoldableBox(inkex.Effect):
+
+ def __init__(self):
+ inkex.Effect.__init__(self)
+ self.OptionParser.add_option("-x", "--width",
+ action="store", type="float",
+ dest="width", default=10.0,
+ help="The Box Width - in the X dimension")
+ self.OptionParser.add_option("-y", "--height",
+ action="store", type="float",
+ dest="height", default=15.0,
+ help="The Box Height - in the Y dimension")
+ self.OptionParser.add_option("-z", "--depth",
+ action="store", type="float",
+ dest="depth", default=3.0,
+ help="The Box Depth - in the Z dimension")
+ self.OptionParser.add_option("-u", "--unit",
+ action="store", type="string",
+ dest="unit", default="cm",
+ help="The unit of the box dimensions")
+ self.OptionParser.add_option("-p", "--paper-thickness",
+ action="store", type="float",
+ dest="thickness", default=0.01,
+ help="Paper Thickness - sometimes that is important")
+ self.OptionParser.add_option("-t", "--tab-proportion",
+ action="store", type="float",
+ dest="tabProportion", default=0.6,
+ help="Inner tab propotion for upper tab")
+ self.OptionParser.add_option("-g", "--guide-line",
+ action="store", type="inkbool",
+ dest="guideLine", default=True,
+ help="Add guide lines to help the drawing limits")
+
+ def effect(self):
+
+ docW = inkex.unittouu(self.document.getroot().get('width'))
+ docH = inkex.unittouu(self.document.getroot().get('height'))
+
+ boxW = inkex.unittouu( str(self.options.width) + self.options.unit )
+ boxH = inkex.unittouu( str(self.options.height) + self.options.unit )
+ boxD = inkex.unittouu( str(self.options.depth) + self.options.unit )
+ tabProp = self.options.tabProportion
+ tabH = boxD * tabProp
+
+ box_id = self.uniqueId('box')
+ g = inkex.etree.SubElement(self.current_layer, 'g', {'id':box_id})
+
+ line_style = simplestyle.formatStyle({ 'stroke': '#000000', 'fill': 'none' })
+
+ #self.createGuide( 0, docH, 0 );
+
+ # Inner Close Tab
+ line_path = [
+ [ 'M', [ boxW-(tabH*0.7), 0 ] ],
+ [ 'C', [ boxW-(tabH*0.25), 0, boxW, tabH*0.3, boxW, tabH*0.9 ] ],
+ [ 'L', [ boxW, tabH ] ],
+ [ 'L', [ 0, tabH ] ],
+ [ 'L', [ 0, tabH*0.9 ] ],
+ [ 'C', [ 0, tabH*0.3, tabH*0.25, 0, tabH*0.7, 0 ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-inner-close-tab', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ lower_pos = boxD+tabH
+ left_pos = 0
+
+ #self.createGuide( 0, docH-tabH, 0 );
+
+ # Upper Close Tab
+ line_path = [
+ [ 'M', [ left_pos, tabH ] ],
+ [ 'L', [ left_pos + boxW, tabH ] ],
+ [ 'L', [ left_pos + boxW, lower_pos ] ],
+ [ 'L', [ left_pos + 0, lower_pos ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-upper-close-tab', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ left_pos += boxW
+
+ # Upper Right Tab
+ sideTabH = lower_pos - (boxW/2)
+ if sideTabH < tabH: sideTabH = tabH
+ line_path = [
+ [ 'M', [ left_pos, sideTabH ] ],
+ [ 'L', [ left_pos + (boxD*0.8), sideTabH ] ],
+ [ 'L', [ left_pos + boxD, ((lower_pos*3)-sideTabH)/3 ] ],
+ [ 'L', [ left_pos + boxD, lower_pos ] ],
+ [ 'L', [ left_pos + 0, lower_pos ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-upper-right-tab', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ left_pos += boxW + boxD
+
+ # Upper Left Tab
+ line_path = [
+ [ 'M', [ left_pos + boxD, sideTabH ] ],
+ [ 'L', [ left_pos + (boxD*0.2), sideTabH ] ],
+ [ 'L', [ left_pos, ((lower_pos*3)-sideTabH)/3 ] ],
+ [ 'L', [ left_pos, lower_pos ] ],
+ [ 'L', [ left_pos + boxD, lower_pos ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-upper-left-tab', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ left_pos = 0
+
+ #self.createGuide( 0, docH-tabH-boxD, 0 );
+
+ # Right Tab
+ line_path = [
+ [ 'M', [ left_pos, lower_pos ] ],
+ [ 'L', [ left_pos - (boxD/2), lower_pos + (boxD/4) ] ],
+ [ 'L', [ left_pos - (boxD/2), lower_pos + boxH - (boxD/4) ] ],
+ [ 'L', [ left_pos, lower_pos + boxH ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-left-tab', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ # Front
+ line_path = [
+ [ 'M', [ left_pos, lower_pos ] ],
+ [ 'L', [ left_pos + boxW, lower_pos ] ],
+ [ 'L', [ left_pos + boxW, lower_pos + boxH ] ],
+ [ 'L', [ left_pos, lower_pos + boxH ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-front', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ left_pos += boxW
+
+ # Right
+ line_path = [
+ [ 'M', [ left_pos, lower_pos ] ],
+ [ 'L', [ left_pos + boxD, lower_pos ] ],
+ [ 'L', [ left_pos + boxD, lower_pos + boxH ] ],
+ [ 'L', [ left_pos, lower_pos + boxH ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-right', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ left_pos += boxD
+
+ # Back
+ line_path = [
+ [ 'M', [ left_pos, lower_pos ] ],
+ [ 'L', [ left_pos + boxW, lower_pos ] ],
+ [ 'L', [ left_pos + boxW, lower_pos + boxH ] ],
+ [ 'L', [ left_pos, lower_pos + boxH ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-back', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ left_pos += boxW
+
+ # Left
+ line_path = [
+ [ 'M', [ left_pos, lower_pos ] ],
+ [ 'L', [ left_pos + boxD, lower_pos ] ],
+ [ 'L', [ left_pos + boxD, lower_pos + boxH ] ],
+ [ 'L', [ left_pos, lower_pos + boxH ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-left', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ lower_pos += boxH
+ left_pos = 0
+ bTab = lower_pos + boxD
+ if bTab > boxW / 2.5: bTab = boxW / 2.5
+
+ # Bottom Front Tab
+ line_path = [
+ [ 'M', [ left_pos, lower_pos ] ],
+ [ 'L', [ left_pos, lower_pos + (boxD/2) ] ],
+ [ 'L', [ left_pos + boxW, lower_pos + (boxD/2) ] ],
+ [ 'L', [ left_pos + boxW, lower_pos ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-bottom-front-tab', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ left_pos += boxW
+
+ # Bottom Right Tab
+ line_path = [
+ [ 'M', [ left_pos, lower_pos ] ],
+ [ 'L', [ left_pos, lower_pos + bTab ] ],
+ [ 'L', [ left_pos + boxD, lower_pos + bTab ] ],
+ [ 'L', [ left_pos + boxD, lower_pos ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-bottom-right-tab', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ left_pos += boxD
+
+ # Bottom Back Tab
+ line_path = [
+ [ 'M', [ left_pos, lower_pos ] ],
+ [ 'L', [ left_pos, lower_pos + (boxD/2) ] ],
+ [ 'L', [ left_pos + boxW, lower_pos + (boxD/2) ] ],
+ [ 'L', [ left_pos + boxW, lower_pos ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-bottom-back-tab', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ left_pos += boxW
+
+ # Bottom Left Tab
+ line_path = [
+ [ 'M', [ left_pos, lower_pos ] ],
+ [ 'L', [ left_pos, lower_pos + bTab ] ],
+ [ 'L', [ left_pos + boxD, lower_pos + bTab ] ],
+ [ 'L', [ left_pos + boxD, lower_pos ] ],
+ [ 'Z', [] ]
+ ]
+ line_atts = { 'style':line_style, 'id':box_id+'-bottom-left-tab', 'd':formatPath(line_path) }
+ inkex.etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
+
+ left_pos += boxD
+ lower_pos += bTab
+
+ g.set( 'transform', 'translate(%f,%f)' % ( (docW-left_pos)/2, (docH-lower_pos)/2 ) )
+
+if __name__ == '__main__':
+ e = FoldableBox()
+ e.affect()
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
diff --git a/share/extensions/test/foldablebox.test.py b/share/extensions/test/foldablebox.test.py
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+import sys
+sys.path.append('..') # this line allows to import the extension code
+
+import unittest, calendar
+from foldablebox import *
+
+class FoldableBoxArguments(unittest.TestCase):
+
+ #def setUp(self):
+
+ def test_default_names_list(self):
+ args = [ 'minimal-blank.svg' ]
+ e = FoldableBox()
+ e.affect( args, False )
+ self.assertEqual( e.options.width, 10.0 )
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/share/extensions/test/run-all-extension-tests b/share/extensions/test/run-all-extension-tests
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+echo "
+ #########################
+ Extension Tests
+ #########################"
+
+cd "$(dirname "$0")"
+
+has_py_coverage=false
+py_cover_files=$( mktemp )
+
+if coverage.py -e >/dev/null 2>/dev/null; then
+ has_py_coverage=true
+ cover_py_cmd=coverage.py
+else
+ if coverage -e >/dev/null 2>/dev/null; then
+ has_py_coverage=true
+ cover_py_cmd=coverage
+ fi
+fi
+
+#if $has_py_coverage; then
+# $cover_py_cmd -e
+#fi
+
+function run_py_test() {
+ echo -e "\n>> Testing $1"
+ if $has_py_coverage; then
+ $cover_py_cmd -x "$1.test.py"
+ echo "../$1.py" >> $py_cover_files
+ else
+ python "$1.test.py"
+ fi
+}
+
+run_py_test svgcalendar
+run_py_test foldablebox
+
+echo ""
+if $has_py_coverage; then
+ cat $py_cover_files | xargs $cover_py_cmd -r
+fi
+
+rm $py_cover_files