Add new template generator

pull/125/head
Windell Oskay 2019-06-19 20:33:59 -07:00
rodzic 588e57b00f
commit dd640bba93
2 zmienionych plików z 75 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape">
<_name>EggBot Template</_name>
<id>org.inkscape.render.empty_eggbot</id>
<dependency type="executable" location="extensions">empty_eggbot.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<!--
<param name="layer" type="boolean" _gui-text="Include default layer">true</param>
-->
<param name="width" _gui-text="Custom Width (default 3200):" type="float" min="1" max="12800">3200</param>
<param name="height" _gui-text="Custom Height (default 800):" type="float" min="1" max="3200">800</param>
<effect needs-live-preview="false">
<object-type>all</object-type>
<effects-menu hidden="true" />
</effect>
<inkscape:_templateinfo>
<inkscape:_name>EggBot Template</inkscape:_name>
<inkscape:author>Windell Oskay</inkscape:author>
<inkscape:_shortdesc>A blank document for EggBot drawing</inkscape:_shortdesc>
<inkscape:date>2019-06-19</inkscape:date>
<inkscape:_keywords>eggbot</inkscape:_keywords>
</inkscape:_templateinfo>
<script>
<command reldir="extensions" interpreter="python">empty_eggbot.py</command>
</script>
</inkscape-extension>

Wyświetl plik

@ -0,0 +1,44 @@
#!/usr/bin/env python
# Adapted from generic template by Tavmjong Bah
import inkex
import re
class C(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.OptionParser.add_option("-w", "--width", action="store", type="int", dest="generic_width", default="1920", help="Custom width")
self.OptionParser.add_option("-z", "--height", action="store", type="int", dest="generic_height", default="1080", help="Custom height")
def effect(self):
width = self.options.generic_width
height = self.options.generic_height
unit = "px"
root = self.document.getroot()
root.set("id", "SVGRoot")
root.set("width", str(width) + unit)
root.set("height", str(height) + unit)
root.set("viewBox", "0 0 " + str(width) + " " + str(height) )
namedview = root.find(inkex.addNS('namedview', 'sodipodi'))
if namedview is None:
namedview = inkex.etree.SubElement( root, inkex.addNS('namedview', 'sodipodi') );
namedview.set(inkex.addNS('document-units', 'inkscape'), unit)
# Until units are supported in 'cx', etc.
namedview.set(inkex.addNS('zoom', 'inkscape'), str(512.0/self.uutounit( width, 'px' )) )
namedview.set(inkex.addNS('cx', 'inkscape'), str(self.uutounit( width, 'px' )/2.0 ) )
namedview.set(inkex.addNS('cy', 'inkscape'), str(self.uutounit( height, 'px' )/2.0 ) )
namedview.set( 'pagecolor', "#ffffff" )
namedview.set( 'bordercolor', "#666666" )
namedview.set(inkex.addNS('pageopacity', 'inkscape'), "1.0" )
namedview.set(inkex.addNS('pageshadow', 'inkscape'), "0" )
c = C()
c.affect()