added unit option for maze generator

This commit is contained in:
Mario Voigt 2021-05-23 15:18:29 +02:00
parent 3796682a43
commit c6000b4ada
2 changed files with 14 additions and 6 deletions

View File

@ -2,9 +2,16 @@
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Maze</name> <name>Maze</name>
<id>fablabchemnitz.de.maze</id> <id>fablabchemnitz.de.maze</id>
<param name="verti" type="int" min="2" max="1000" gui-text="Height">20</param> <param name="verti" type="int" min="2" max="1000" gui-text="Height (cells)">20</param>
<param name="horiz" type="int" min="2" max="1000" gui-text="Length">20</param> <param name="horiz" type="int" min="2" max="1000" gui-text="Length (cells)">20</param>
<param name="size" type="float" max="100.0" gui-text="Cell Size">10.0</param> <param name="size" type="float" max="100.0" gui-text="Cell Size">10.0</param>
<param name="cell_units" gui-text="Cell units" type="optiongroup" appearance="combo">
<option value="px">px</option>
<option value="pt">pt</option>
<option value="in">in</option>
<option value="cm">cm</option>
<option value="mm">mm</option>
</param>
<param name="width" type="float" gui-text="Line Width">1.0</param> <param name="width" type="float" gui-text="Line Width">1.0</param>
<param name="algo" type="optiongroup" appearance="combo" gui-text="Algorithm"> <param name="algo" type="optiongroup" appearance="combo" gui-text="Algorithm">
<option value="kruskal">Kruskal</option> <option value="kruskal">Kruskal</option>

View File

@ -27,9 +27,10 @@ def points_to_svgd(p, close=False):
class Recursive(inkex.EffectExtension): class Recursive(inkex.EffectExtension):
def add_arguments(self, pars): def add_arguments(self, pars):
pars.add_argument("--verti", type=int, default=20, help="Height") pars.add_argument("--verti", type=int, default=20, help="Height (cells)")
pars.add_argument("--horiz", type=int, default=20, help="Length") pars.add_argument("--horiz", type=int, default=20, help="Length (cells)")
pars.add_argument("--size", type=float, default=10.0, help="Cell Size") pars.add_argument("--size", type=float, default=10.0, help="Cell size")
pars.add_argument("--cell_units", default="mm", help="Units")
pars.add_argument("--algo", default=1, help="Algorithm") pars.add_argument("--algo", default=1, help="Algorithm")
pars.add_argument("--width", type=float, default=10.0, help="Line width") pars.add_argument("--width", type=float, default=10.0, help="Line width")
@ -39,7 +40,7 @@ class Recursive(inkex.EffectExtension):
# my group of paths # my group of paths
topgroup = etree.SubElement(self.svg.get_current_layer(), 'g' ) topgroup = etree.SubElement(self.svg.get_current_layer(), 'g' )
lc = self.options.size lc = self.svg.unittouu (str(self.options.size) + self.options.cell_units)
X = self.options.verti X = self.options.verti
Y = self.options.horiz Y = self.options.horiz