From d2d46b5e9228a21330720e7c8ccce353ced02b72 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 26 May 2014 13:37:44 +0200 Subject: Convert from 90px to inch to 96px to inch per SVG (CSS) specification. (bzr r13341.1.39) --- share/extensions/inkex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index 947cb5b30..a8adfa43d 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -285,8 +285,8 @@ class Effect: return 'px' #a dictionary of unit to user unit conversion factors - __uuconv = {'in':90.0, 'pt':1.25, 'px':1.0, 'mm':3.5433070866, 'cm':35.433070866, 'm':3543.3070866, - 'km':3543307.0866, 'pc':15.0, 'yd':3240.0 , 'ft':1080.0} + __uuconv = {'in':96.0, 'pt':1.33333333333, 'px':1.0, 'mm':3.77952755913, 'cm':37.7952755913, + 'm':3779.52755913, 'km':3779527.55913, 'pc':16.0, 'yd':3456.0 , 'ft':1152.0} def unittouu(self, string): '''Returns userunits given a string representation of units in another system''' unit = re.compile('(%s)$' % '|'.join(self.__uuconv.keys())) -- cgit v1.2.3 From 686e7a0457801d6b06959475a85bc107146b2055 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 21 Jun 2014 21:46:31 +0200 Subject: Add new named color 'rebeccapurple' (CSS4 Color). (bzr r13341.1.65) --- share/extensions/colors.xml | 1 + share/extensions/scour.py | 1 + share/extensions/simplestyle.py | 1 + 3 files changed, 3 insertions(+) (limited to 'share/extensions') diff --git a/share/extensions/colors.xml b/share/extensions/colors.xml index 51167fdd7..7ed8592d5 100644 --- a/share/extensions/colors.xml +++ b/share/extensions/colors.xml @@ -119,6 +119,7 @@ + diff --git a/share/extensions/scour.py b/share/extensions/scour.py index be40a27bd..236529daa 100644 --- a/share/extensions/scour.py +++ b/share/extensions/scour.py @@ -250,6 +250,7 @@ colors = { 'plum': 'rgb(221, 160, 221)', 'powderblue': 'rgb(176, 224, 230)', 'purple': 'rgb(128, 0, 128)', + 'rebeccapurple': 'rgb(102, 51, 153)', 'red': 'rgb(255, 0, 0)', 'rosybrown': 'rgb(188, 143, 143)', 'royalblue': 'rgb( 65, 105, 225)', diff --git a/share/extensions/simplestyle.py b/share/extensions/simplestyle.py index 99b5938dd..806b81813 100644 --- a/share/extensions/simplestyle.py +++ b/share/extensions/simplestyle.py @@ -141,6 +141,7 @@ svgcolors={ 'plum':'#dda0dd', 'powderblue':'#b0e0e6', 'purple':'#800080', + 'rebeccapurple':'#663399', 'red':'#ff0000', 'rosybrown':'#bc8f8f', 'royalblue':'#4169e1', -- cgit v1.2.3 From 413b305c3fa06f490cf730cb61387012714eb316 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 8 Oct 2014 15:53:03 +0200 Subject: Fixed 'viewBox', added 'inkscape:cx' and 'inkscape:cy'. (bzr r13341.1.259) --- share/extensions/empty_page.py | 77 ++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 30 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/empty_page.py b/share/extensions/empty_page.py index dc16bab97..34dee7fc4 100644 --- a/share/extensions/empty_page.py +++ b/share/extensions/empty_page.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +# Rewritten by Tavmjong Bah to add correct viewBox, inkscape:cx, etc. attributes + import inkex class C(inkex.Effect): @@ -8,37 +10,52 @@ class C(inkex.Effect): self.OptionParser.add_option("-s", "--size", action="store", type="string", dest="page_size", default="a4", help="Page size") self.OptionParser.add_option("-o", "--orientation", action="store", type="string", dest="page_orientation", default="vertical", help="Page orientation") - def effect(self): + def effect(self): + + width = 300 + height = 300 + units = 'px' + + if self.options.page_size == "a5": + width = 148 + height= 210 + units = 'mm' + + if self.options.page_size == "a4": + width = 210 + height= 297 + units = 'mm' + + if self.options.page_size == "a3": + width = 297 + height= 420 + units = 'mm' + + if self.options.page_size == "letter": + width = 8.5 + height = 11 + units = 'in' + + if self.options.page_orientation == "horizontal": + width, height = height, width + + root = self.document.getroot() - root.set("width", "12in") - root.set("height", "12in") - if self.options.page_size == "a4" and self.options.page_orientation == "vertical": - root.set("width", "210mm") - root.set("height", "297mm") - if self.options.page_size == "a4" and self.options.page_orientation == "horizontal": - root.set("height", "210mm") - root.set("width", "297mm") - - if self.options.page_size == "a5" and self.options.page_orientation == "vertical": - root.set("width", "148mm") - root.set("height", "210mm") - if self.options.page_size == "a5" and self.options.page_orientation == "horizontal": - root.set("width", "210mm") - root.set("height", "148mm") - - if self.options.page_size == "a3" and self.options.page_orientation == "vertical": - root.set("width", "297mm") - root.set("height", "420mm") - if self.options.page_size == "a3" and self.options.page_orientation == "horizontal": - root.set("width", "420mm") - root.set("height", "297mm") - - if self.options.page_size == "letter" and self.options.page_orientation == "vertical": - root.set("width", "8.5in") - root.set("height", "11in") - if self.options.page_size == "letter" and self.options.page_orientation == "horizontal": - root.set("width", "11in") - root.set("height", "8.5in") + root.set("id", "SVGRoot") + root.set("width", str(width) + units) + root.set("height", str(height) + units) + 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'), units) + + # Until units are supported in 'cx', etc. + 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 ) ) + c = C() c.affect() -- cgit v1.2.3 From dcf222167e512abb39c83f6e885ed35ea8b1e802 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 8 Oct 2014 20:36:22 +0200 Subject: Add proper 'viewBox', set 'inkscape:document-units', increased maximum emsize to 2048 (typical of TrueType). (bzr r13341.1.261) --- share/extensions/setup_typography_canvas.inx | 10 +++++----- share/extensions/setup_typography_canvas.py | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/setup_typography_canvas.inx b/share/extensions/setup_typography_canvas.inx index 332a14ade..8e7739b5c 100644 --- a/share/extensions/setup_typography_canvas.inx +++ b/share/extensions/setup_typography_canvas.inx @@ -4,11 +4,11 @@ org.inkscape.typography.setuptypographycanvas inkex.py setup_typography_canvas.py - 1000 - 750 - 700 - 500 - 250 + 1000 + 750 + 700 + 500 + 250 all diff --git a/share/extensions/setup_typography_canvas.py b/share/extensions/setup_typography_canvas.py index 197aeb77e..a1000f2d1 100755 --- a/share/extensions/setup_typography_canvas.py +++ b/share/extensions/setup_typography_canvas.py @@ -69,6 +69,7 @@ class SetupTypographyCanvas(inkex.Effect): self.svg = self.document.getroot() self.svg.set("width", str(emsize)) self.svg.set("height", str(emsize)) + self.svg.set("viewBox", "0 0 " + str(emsize) + " " + str(emsize) ) baseline = descender # Create guidelines @@ -78,6 +79,12 @@ class SetupTypographyCanvas(inkex.Effect): self.create_horizontal_guideline("xheight", baseline+xheight) self.create_horizontal_guideline("descender", baseline-descender) + namedview = self.svg.find(inkex.addNS('namedview', 'sodipodi')) + namedview.set(inkex.addNS('document-units', 'inkscape'), 'px') + namedview.set(inkex.addNS('cx', 'inkscape'), str(emsize/2.0 )) + namedview.set(inkex.addNS('cy', 'inkscape'), str(emsize/2.0 )) + + if __name__ == '__main__': e = SetupTypographyCanvas() e.affect() -- cgit v1.2.3 From 08851e26fdc2a5f52affae67fd1fb913a512cfe1 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 10 Oct 2014 20:55:11 +0200 Subject: Added background and no border options. (bzr r13341.1.266) --- share/extensions/empty_page.inx | 21 +++++++++++++++------ share/extensions/empty_page.py | 26 +++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 7 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/empty_page.inx b/share/extensions/empty_page.inx index f3f60f796..6882b7273 100644 --- a/share/extensions/empty_page.inx +++ b/share/extensions/empty_page.inx @@ -1,6 +1,6 @@ - <_name>Empty Page + <_name>Page org.inkscape.render.empty_page empty_page.py inkex.py @@ -16,17 +16,26 @@ Horizontal Vertical - + + + Normal + Black Opaque + Gray Opaque + White Opaque + + + false + all - Empty page - Jan Darowski + Page... + Jan Darowski, updated by Tavmjong Bah Empty page of chosen size. - 2013-09-10 - empty sheet a4 a3 a5 letter + 2014-10-06 + empty sheet a4 a3 a5 letter black white opaque + diff --git a/share/extensions/empty_business_card.py b/share/extensions/empty_business_card.py new file mode 100644 index 000000000..586c37abc --- /dev/null +++ b/share/extensions/empty_business_card.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +# Written by Tavmjong Bah + +import inkex +import re + +class C(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("-s", "--size", action="store", type="string", dest="card_size", default="90mmx55mm", help="Business card size") + + def effect(self): + + size = self.options.card_size + + p = re.compile('([0-9.]*)([a-z][a-z])x([0-9.]*)([a-z][a-z])') + m = p.match( size ) + width = m.group(1) + width_unit = m.group(2) + height = m.group(3) + height_unit = m.group(4) + + root = self.document.getroot() + root.set("id", "SVGRoot") + root.set("width", width + width_unit) + root.set("height", height + height_unit) + root.set("viewBox", "0 0 " + width + " " + 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'), width_unit) + + width_int = int(self.uutounit(float(width), 'px')) + height_int = int(self.uutounit(float(height), 'px')) + + namedview.set(inkex.addNS('zoom', 'inkscape'), str(2) ) + namedview.set(inkex.addNS('cx', 'inkscape'), str(width_int/2.0) ) + namedview.set(inkex.addNS('cy', 'inkscape'), str(height_int/2.0) ) + + +c = C() +c.affect() diff --git a/share/extensions/empty_desktop.inx b/share/extensions/empty_desktop.inx new file mode 100644 index 000000000..75762b660 --- /dev/null +++ b/share/extensions/empty_desktop.inx @@ -0,0 +1,39 @@ + + + <_name>Desktop + org.inkscape.render.empty_desktop + empty_desktop.py + inkex.py + + + Custom + 640x480 (VGA) + 800x600 (SVGA) + 1024x768 (XGA) + 1366x768 (HD) + 1600x900 (HD+) + 1600x1200 (UXGA) + 1920x1080 (FHD) + 1920x1200 (WUXGA) + 2560x1600 (WQXGA) + + + + 1920 + 1080 + + + all + + + Desktop... + Tavmjong Bah + Empty desktop of chosen size. + 2014-10-09 + empty desktop + + + diff --git a/share/extensions/empty_desktop.py b/share/extensions/empty_desktop.py new file mode 100644 index 000000000..31cb35f9d --- /dev/null +++ b/share/extensions/empty_desktop.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +# Written by Tavmjong Bah + +import inkex +import re + +class C(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("-s", "--size", action="store", type="string", dest="desktop_size", default="16", help="Desktop size") + + self.OptionParser.add_option("-w", "--width", action="store", type="int", dest="desktop_width", default="1920", help="Custom width") + self.OptionParser.add_option("-z", "--height", action="store", type="int", dest="desktop_height", default="1080", help="Custom height") + + def effect(self): + + size = self.options.desktop_size + width = self.options.desktop_width + height = self.options.desktop_height + + if size != "Custom": + p = re.compile('([0-9]*)x([0-9]*)') + m = p.match( size ) + width = int(m.group(1)) + height = int(m.group(2)) + + + root = self.document.getroot() + root.set("id", "SVGRoot") + root.set("width", str(width) + 'px') + root.set("height", str(height) + 'px') + 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'), 'px') + + namedview.set(inkex.addNS('cx', 'inkscape'), str(width/2.0) ) + namedview.set(inkex.addNS('cy', 'inkscape'), str(height/2.0) ) + + +c = C() +c.affect() diff --git a/share/extensions/empty_dvd_cover.inx b/share/extensions/empty_dvd_cover.inx new file mode 100644 index 000000000..facb523d1 --- /dev/null +++ b/share/extensions/empty_dvd_cover.inx @@ -0,0 +1,31 @@ + + + <_name>DVD Cover + org.inkscape.render.empty_dvd_cover + empty_dvd_cover.py + inkex.py + + + Normal (14mm) + Slim (9mm) + Super Slim (7mm) + Ultra Slim (5mm) + + + 3 + + + all + + + DVD Cover... + Tavmjong Bah + DVD cover of chosen size. + 2014-10-10 + dvd cover + + + diff --git a/share/extensions/empty_dvd_cover.py b/share/extensions/empty_dvd_cover.py new file mode 100644 index 000000000..1456de51d --- /dev/null +++ b/share/extensions/empty_dvd_cover.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +# Written by Tavmjong Bah + +import inkex + +class C(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("-s", "--spine", action="store", type="string", dest="dvd_cover_spine", default="normal", help="Dvd spine width") + self.OptionParser.add_option("-b", "--bleed", action="store", type="float", dest="dvd_cover_bleed", default="3", help="Bleed (extra area around image") + + def create_horizontal_guideline(self, name, position): + self.create_guideline(name, "0,1", 0, position) + + def create_vertical_guideline(self, name, position): + self.create_guideline(name, "1,0", position, 0) + + def create_guideline(self, label, orientation, x,y): + namedview = self.root.find(inkex.addNS('namedview', 'sodipodi')) + guide = inkex.etree.SubElement(namedview, inkex.addNS('guide', 'sodipodi')) + guide.set("orientation", orientation) + guide.set("position", str(x)+","+str(y)) + # No need to set label (causes translation problems, etc.) + # guide.set(inkex.addNS('label', 'inkscape'), label) + + def effect(self): + + # Dimensions in mm + width = 259.0 # Before adding spine width or bleed + height = 183.0 # Before adding bleed + + bleed = self.options.dvd_cover_bleed + spine = float( self.options.dvd_cover_spine ) + + width += spine + width += 2.0 * bleed + height += 2.0 * bleed + + self.root = self.document.getroot() + self.root.set("id", "SVGRoot") + self.root.set("width", str(width) + 'mm') + self.root.set("height", str(height) + 'mm') + self.root.set("viewBox", "0 0 " + str(width) + " " + str(height) ) + + namedview = self.root.find(inkex.addNS('namedview', 'sodipodi')) + if namedview is None: + namedview = inkex.etree.SubElement( self.root, inkex.addNS('namedview', 'sodipodi') ); + + namedview.set(inkex.addNS('document-units', 'inkscape'), "mm") + + # Until units are supported in 'cx', etc. + 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 ) ) + + self.create_horizontal_guideline("bottom", str(self.uutounit( bleed, 'px' )) ) + self.create_horizontal_guideline("top", str(self.uutounit( height-bleed, 'px' )) ) + self.create_vertical_guideline("left edge", str(self.uutounit( bleed, 'px' )) ) + self.create_vertical_guideline("left spline", str(self.uutounit( (width-spine)/2.0,'px' )) ) + self.create_vertical_guideline("right spline", str(self.uutounit( (width+spine)/2.0,'px' )) ) + self.create_vertical_guideline("left edge", str(self.uutounit( width-bleed, 'px' )) ) + +c = C() +c.affect() diff --git a/share/extensions/empty_generic.inx b/share/extensions/empty_generic.inx new file mode 100644 index 000000000..b430cfba5 --- /dev/null +++ b/share/extensions/empty_generic.inx @@ -0,0 +1,47 @@ + + + <_name>Generic Canvas + org.inkscape.render.empty_generic_canvas + empty_generic.py + inkex.py + + 800 + 600 + + + 'px' + 'in' + 'mm' + 'cm' + 'pc' + 'pt' + + + + Normal + Black Opaque + Gray Opaque + White Opaque + + + false + + + + + all + + + Generic canvas... + Tavmjong Bah + Genric canvas of choosen size. + 2014-10-09 + empty generic canvas + + + diff --git a/share/extensions/empty_generic.py b/share/extensions/empty_generic.py new file mode 100644 index 000000000..62e27d220 --- /dev/null +++ b/share/extensions/empty_generic.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python + +# Written 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") + self.OptionParser.add_option("-u", "--unit", action="store", type="string", dest="generic_unit", default="px", help="SVG Unit") + self.OptionParser.add_option("-b", "--background", action="store", type="string", dest="generic_background", default="normal", help="Canvas background") + self.OptionParser.add_option("-n", "--noborder", action="store", type="inkbool", dest="generic_noborder", default=False) + # self.OptionParser.add_option("-l", "--layer", action="store", type="inkbool", dest="generic_layer", default=True) + + def effect(self): + + width = self.options.generic_width + height = self.options.generic_height + unit = self.options.generic_unit + + 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 ) ) + + if self.options.generic_background == "white": + namedview.set( 'pagecolor', "#ffffff" ) + namedview.set( 'bordercolor', "#666666" ) + namedview.set(inkex.addNS('pageopacity', 'inkscape'), "1.0" ) + namedview.set(inkex.addNS('pageshadow', 'inkscape'), "0" ) + + if self.options.generic_background == "gray": + namedview.set( 'pagecolor', "#808080" ) + namedview.set( 'bordercolor', "#444444" ) + namedview.set(inkex.addNS('pageopacity', 'inkscape'), "1.0" ) + namedview.set(inkex.addNS('pageshadow', 'inkscape'), "0" ) + + if self.options.generic_background == "black": + namedview.set( 'pagecolor', "#000000" ) + namedview.set( 'bordercolor', "#999999" ) + namedview.set(inkex.addNS('pageopacity', 'inkscape'), "1.0" ) + namedview.set(inkex.addNS('pageshadow', 'inkscape'), "0" ) + + if self.options.generic_noborder: + pagecolor = namedview.get( 'pagecolor' ) + namedview.set( 'bordercolor', pagecolor ) + namedview.set( 'borderopacity', "0" ) + + # This nees more thought... we need to set "Current layer" to (root), how? + # if self.options.generic_layer: + # # Add layer + # inkex.debug( "We want a layer" ) + # else: + # # Remove layer id default document (assuming only one) + # inkex.debug( "We don't want a layer" ) + # layer_node = self.current_layer + # if layer_node is not None: + # inkex.debug( "We have layer" ) + # root.remove(layer_node) + # try: + # del namedview.attrib[ inkex.addNS('current-layer', 'inkscape') ] + # except: + # pass + + +c = C() +c.affect() diff --git a/share/extensions/empty_icon.inx b/share/extensions/empty_icon.inx new file mode 100644 index 000000000..9e36b9d20 --- /dev/null +++ b/share/extensions/empty_icon.inx @@ -0,0 +1,24 @@ + + + <_name>Icon + org.inkscape.render.empty_icon + empty_icon.py + inkex.py + + 16 + + + all + + + Icon... + Tavmjong Bah + Empty icon of chosen size. + 2014-10-09 + empty icon + + + diff --git a/share/extensions/empty_icon.py b/share/extensions/empty_icon.py new file mode 100644 index 000000000..979edbae4 --- /dev/null +++ b/share/extensions/empty_icon.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +# Written by Tavmjong Bah + +import inkex + +class C(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("-s", "--size", action="store", type="int", dest="icon_size", default="16", help="Icon size") + + def effect(self): + + size = self.options.icon_size + + root = self.document.getroot() + root.set("id", "SVGRoot") + root.set("width", str(size) + 'px') + root.set("height", str(size) + 'px') + root.set("viewBox", "0 0 " + str(size) + " " + str(size) ) + + 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'), 'px') + + namedview.set(inkex.addNS('zoom', 'inkscape'), str(256.0/size) ) + namedview.set(inkex.addNS('cx', 'inkscape'), str(size/2.0) ) + namedview.set(inkex.addNS('cy', 'inkscape'), str(size/2.0) ) + namedview.set(inkex.addNS('grid-bbox', 'inkscape'), "true" ) + + + +c = C() +c.affect() diff --git a/share/extensions/empty_video.inx b/share/extensions/empty_video.inx new file mode 100644 index 000000000..8ca148cfc --- /dev/null +++ b/share/extensions/empty_video.inx @@ -0,0 +1,35 @@ + + + <_name>Video Screen + org.inkscape.render.empty_video + empty_video.py + inkex.py + + + Custom + 720x486 (NTSC) + 720x576 (PAL) + 1920x1080 (HDTV) + 3840x2160 (4K) + 7680x4320 (8K) + + + + 1920 + 1080 + + + all + + + Video... + Tavmjong Bah + Video screen of chosen size. + 2014-10-09 + empty video + + + diff --git a/share/extensions/empty_video.py b/share/extensions/empty_video.py new file mode 100644 index 000000000..4b440704c --- /dev/null +++ b/share/extensions/empty_video.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +# Written by Tavmjong Bah + +import inkex +import re + +class C(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("-s", "--size", action="store", type="string", dest="video_size", default="16", help="Video size") + + self.OptionParser.add_option("-w", "--width", action="store", type="int", dest="video_width", default="1920", help="Custom width") + self.OptionParser.add_option("-z", "--height", action="store", type="int", dest="video_height", default="1080", help="Custom height") + + def effect(self): + + size = self.options.video_size + width = self.options.video_width + height = self.options.video_height + + if size != "Custom": + p = re.compile('([0-9]*)x([0-9]*)') + m = p.match( size ) + width = int(m.group(1)) + height = int(m.group(2)) + + + root = self.document.getroot() + root.set("id", "SVGRoot") + root.set("width", str(width) + 'px') + root.set("height", str(height) + 'px') + 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'), 'px') + + namedview.set(inkex.addNS('cx', 'inkscape'), str(width/2.0) ) + namedview.set(inkex.addNS('cy', 'inkscape'), str(height/2.0) ) + + +c = C() +c.affect() -- cgit v1.2.3 From 30e1225c143c459dd0623f762c8f51425b2d822c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 19 Oct 2014 19:49:35 +0200 Subject: Add seamless patern generator to a extension and to a procedural template (bzr r13341.1.281) --- share/extensions/seamless_pattern.inx | 20 +++ share/extensions/seamless_pattern.py | 213 +++++++++++++++++++++++ share/extensions/seamless_pattern.svg | 85 +++++++++ share/extensions/seamless_pattern_procedural.inx | 25 +++ 4 files changed, 343 insertions(+) create mode 100644 share/extensions/seamless_pattern.inx create mode 100755 share/extensions/seamless_pattern.py create mode 100644 share/extensions/seamless_pattern.svg create mode 100644 share/extensions/seamless_pattern_procedural.inx (limited to 'share/extensions') diff --git a/share/extensions/seamless_pattern.inx b/share/extensions/seamless_pattern.inx new file mode 100644 index 000000000..fe4098e05 --- /dev/null +++ b/share/extensions/seamless_pattern.inx @@ -0,0 +1,20 @@ + + + <_name>Seamless Pattern + org.inkscape.render.seamless_pattern + seamless_pattern.py + inkex.py + 100 + 100 + <_param name="help-info" type="description">This extension overwrite current document + + + All + + + + + + diff --git a/share/extensions/seamless_pattern.py b/share/extensions/seamless_pattern.py new file mode 100755 index 000000000..f737c4cbc --- /dev/null +++ b/share/extensions/seamless_pattern.py @@ -0,0 +1,213 @@ +#!/usr/bin/env python + +# Written by Jabiertxof +# V.03 + +import inkex +import re +import os +from lxml import etree + +class C(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("-w", "--width", action="store", type="int", dest="desktop_width", default="100", help="Custom width") + self.OptionParser.add_option("-z", "--height", action="store", type="int", dest="desktop_height", default="100", help="Custom height") + + def effect(self): + + width = self.options.desktop_width + height = self.options.desktop_height + path = os.path.dirname(os.path.realpath(__file__)) + self.document = etree.parse(os.path.join(path, "seamless_pattern.svg")) + root = self.document.getroot() + root.set("id", "SVGRoot") + root.set("width", str(width) + 'px') + root.set("height", str(height) + 'px') + root.set("viewBox", "0 0 " + str(width) + " " + str(height) ) + + xpathStr = '//svg:use[@id="sampleTile"]' + sampleTile = root.xpath(xpathStr, namespaces=inkex.NSS) + if sampleTile != []: + sampleTile[0].set("transform", "translate(" + str(width * 6) + ",-" + str(height) + ")") + + + xpathStr = '//svg:use[@id="clipPathRect"]' + clipPathRect = root.xpath(xpathStr, namespaces=inkex.NSS) + if clipPathRect != []: + clipPathRect[0].set("transform", "translate(" + str((width*3)) + "," + str(height) +")") + + xpathStr = '//svg:tspan[@id="infoText"]' + infoText = root.xpath(xpathStr, namespaces=inkex.NSS) + if infoText != []: + infoText[0].text = infoText[0].text.replace("100x100", str(width) + "x" + str(height)) + + xpathStr = '//svg:use[@id="backgroundPattern"]' + backgroundPattern = root.xpath(xpathStr, namespaces=inkex.NSS) + if backgroundPattern != []: + backgroundPattern[0].set("transform", "translate(-" + str(width * 2) + ",0)") + + xpathStr = '//svg:rect[@id="cuadroPattern"]' + cuadroPattern = root.xpath(xpathStr, namespaces=inkex.NSS) + if cuadroPattern != []: + cuadroPattern[0].set("width", str(width)) + cuadroPattern[0].set("height", str(height)) + cuadroPattern[0].set("y", "-" + str(height*2)) + + xpathStr = '//svg:use[@id="cuadroPatternDisenador"]' + cuadroPatternDisenador = root.xpath(xpathStr, namespaces=inkex.NSS) + if cuadroPatternDisenador != []: + cuadroPatternDisenador[0].set("transform", "translate(" + str(width * 3) + "," + str(height) + ")") + + xpathStr = '//svg:g[@id="designZone"]' + designZone = root.xpath(xpathStr, namespaces=inkex.NSS) + if designZone != []: + designZone[0].set("transform", "translate(" + str((width*5)) + ",0)scale(" + str(((width+height)/2)/100.) + ")") + + xpathStr = '//svg:g[@id="patternResult"]' + patternResult = root.xpath(xpathStr, namespaces=inkex.NSS) + if patternResult != []: + patternResult[0].set("transform", "translate(-" + str((width * 3)) + "," + str(height) + ")") + + xpathStr = '//svg:use[@id="patternTileBackground"]' + patternTileBackground = root.xpath(xpathStr, namespaces=inkex.NSS) + if patternTileBackground != []: + patternTileBackground[0].set("transform", "matrix(3,0,0,3," + str((width * 2)) + "," + str(height * 4) + ")") + patternTileBackground[0].set("width", str(width*3)) + patternTileBackground[0].set("height", str(height*3)) + + xpathStr = '//svg:use[@id="patternGenerated"]' + patternGenerated = root.xpath(xpathStr, namespaces=inkex.NSS) + if patternGenerated != []: + patternGenerated[0].set("width", str(width)) + patternGenerated[0].set("height", str(height)) + + xpathStr = '//svg:use[@id="pattern1"]' + pattern1 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern1 != []: + pattern1[0].set("transform", "translate(" + str(-width) + "," + str(-height) + ")") + + xpathStr = '//svg:use[@id="pattern2"]' + pattern2 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern2 != []: + pattern2[0].set("transform", "translate(0," + str(-height) +")" ) + + xpathStr = '//svg:use[@id="pattern3"]' + pattern3 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern3 != []: + pattern3[0].set("transform", "translate(" + str(width) + "," + str(-height) + ")" ) + + xpathStr = '//svg:use[@id="pattern4"]' + pattern4 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern4 != []: + pattern4[0].set("transform", "translate(" + str(-width) + ",0)" ) + + xpathStr = '//svg:use[@id="pattern5"]' + pattern5 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern5 != []: + pattern5[0].set("transform", "translate(0,0)" ) + + xpathStr = '//svg:use[@id="pattern6"]' + pattern6 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern6 != []: + pattern6[0].set("transform", "translate(" + str(width) + ",0)" ) + + xpathStr = '//svg:use[@id="pattern7"]' + pattern7 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern7 != []: + pattern7[0].set("transform", "translate(" + str(-width) + "," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="pattern8"]' + pattern8 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern8 != []: + pattern8[0].set("transform", "translate(0," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="pattern9"]' + pattern9 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern9 != []: + pattern9[0].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="samplePattern1"]' + samplePattern1 = root.xpath(xpathStr, namespaces=inkex.NSS) + if samplePattern1 != []: + samplePattern1[0].set("transform", "translate(" + str(-width) + "," + str(-height) + ")") + + xpathStr = '//svg:use[@id="samplePattern2"]' + samplePattern2 = root.xpath(xpathStr, namespaces=inkex.NSS) + if samplePattern2 != []: + samplePattern2[0].set("transform", "translate(0," + str(-height) +")" ) + + xpathStr = '//svg:use[@id="samplePattern3"]' + samplePattern3 = root.xpath(xpathStr, namespaces=inkex.NSS) + if samplePattern3 != []: + samplePattern3[0].set("transform", "translate(" + str(width) + "," + str(-height) + ")" ) + + xpathStr = '//svg:use[@id="samplePattern4"]' + samplePattern4 = root.xpath(xpathStr, namespaces=inkex.NSS) + if samplePattern4 != []: + samplePattern4[0].set("transform", "translate(" + str(-width) + ",0)" ) + + xpathStr = '//svg:use[@id="samplePattern5"]' + samplePattern5 = root.xpath(xpathStr, namespaces=inkex.NSS) + if samplePattern5 != []: + samplePattern5[0].set("transform", "translate(0,0)" ) + + xpathStr = '//svg:use[@id="samplePattern6"]' + samplePattern6 = root.xpath(xpathStr, namespaces=inkex.NSS) + if samplePattern6 != []: + samplePattern6[0].set("transform", "translate(" + str(width) + ",0)" ) + + xpathStr = '//svg:use[@id="samplePattern7"]' + samplePattern7 = root.xpath(xpathStr, namespaces=inkex.NSS) + if samplePattern7 != []: + samplePattern7[0].set("transform", "translate(" + str(-width) + "," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="samplePattern8"]' + samplePattern8 = root.xpath(xpathStr, namespaces=inkex.NSS) + if samplePattern8 != []: + samplePattern8[0].set("transform", "translate(0," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="samplePattern9"]' + samplePattern9 = root.xpath(xpathStr, namespaces=inkex.NSS) + if samplePattern9 != []: + samplePattern9[0].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) + + xpathStr = '//svg:g[@id="patternPreview"]' + patternPreview = root.xpath(xpathStr, namespaces=inkex.NSS) + if patternPreview != []: + patternPreview[0].set("transform", "translate(0," + str(height*2) + ")" ) + + xpathStr = '//svg:g[@id="helperLayer"]' + helperLayer = root.xpath(xpathStr, namespaces=inkex.NSS) + if helperLayer != []: + helperLayer[0].set("transform", "scale(" + str(width/100.) + "," + str(height/100.) + ")" ) + + xpathStr = '//svg:rect[@id="fondoGris"]' + fondoGris = root.xpath(xpathStr, namespaces=inkex.NSS) + if fondoGris != []: + fondoGris[0].set("transform", "scale(" + str(width/100.) + "," + str(height/100.) + ")" ) + + xpathStr = '//svg:use[@id="patternGenerator" or id="patternPreviewFast"]' + patternGenerator = root.xpath(xpathStr, namespaces=inkex.NSS) + if patternGenerator != []: + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-cx", str(width/2)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-cy", str(height/2)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-w", str(width)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-h", str(height)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-x0", str(width)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-y0", str(height)) + patternGenerator[0].set("width", str(width)) + patternGenerator[0].set("height", 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'), 'px') + + namedview.set(inkex.addNS('cx', 'inkscape'), str((width*8)/2.0) ) + namedview.set(inkex.addNS('cy', 'inkscape'), "0" ) + namedview.set(inkex.addNS('zoom', 'inkscape'), str(0.5 / (((width+height)/2)/100.)) ) + +c = C() +c.affect() diff --git a/share/extensions/seamless_pattern.svg b/share/extensions/seamless_pattern.svg new file mode 100644 index 000000000..e29b52255 --- /dev/null +++ b/share/extensions/seamless_pattern.svg @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + Pattern + Pattern + Pattern + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Backgroundcolor + Seamless PatternExport as page + PREVIEW -export as multiple of tile size 100x100xROWSxCOLS in px Tile it with tiled clones (edit->clones->tiled clones)Or use as pattern. You can copy full patern -grey block- to use on other documents + + Draw inside + + 3x3 Simple translation example + SEAMLESS PATTERN + + + + + + + + + + + + + + + + diff --git a/share/extensions/seamless_pattern_procedural.inx b/share/extensions/seamless_pattern_procedural.inx new file mode 100644 index 000000000..8f11d5746 --- /dev/null +++ b/share/extensions/seamless_pattern_procedural.inx @@ -0,0 +1,25 @@ + + + <_name>Seamless Pattern Procedural + org.inkscape.render.seamless_pattern_procedural + seamless_pattern.py + inkex.py + + 100 + 100 + + + all + + + Seamless Pattern + Jabiertxof + Create seamless patterns. + 2014-10-16 + seamless_patterns + + + -- cgit v1.2.3 From 0e3a5980d8304716a94a5bddba8c5a9ebcf739b2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 20 Oct 2014 21:35:49 +0200 Subject: Fix a bug getting a template file in the seamless extension, also upgrade this extension to a newer version (bzr r13341.1.283) --- share/extensions/Makefile.am | 1 + share/extensions/seamless_pattern.py | 372 +++++++++++++++------------------- share/extensions/seamless_pattern.svg | 105 +++++----- 3 files changed, 207 insertions(+), 271 deletions(-) mode change 100755 => 100644 share/extensions/seamless_pattern.py (limited to 'share/extensions') diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am index e8be5d777..d9d56a362 100644 --- a/share/extensions/Makefile.am +++ b/share/extensions/Makefile.am @@ -24,6 +24,7 @@ otherstuff_DATA = \ aisvg.xslt \ colors.xml \ jessyInk_video.svg \ + seamless_pattern.svg \ svg2fxg.xsl \ svg2xaml.xsl \ xaml2svg.xsl \ diff --git a/share/extensions/seamless_pattern.py b/share/extensions/seamless_pattern.py old mode 100755 new mode 100644 index f737c4cbc..d04675b6b --- a/share/extensions/seamless_pattern.py +++ b/share/extensions/seamless_pattern.py @@ -1,213 +1,159 @@ -#!/usr/bin/env python - -# Written by Jabiertxof -# V.03 - -import inkex -import re -import os -from lxml import etree - -class C(inkex.Effect): - def __init__(self): - inkex.Effect.__init__(self) - self.OptionParser.add_option("-w", "--width", action="store", type="int", dest="desktop_width", default="100", help="Custom width") - self.OptionParser.add_option("-z", "--height", action="store", type="int", dest="desktop_height", default="100", help="Custom height") - - def effect(self): - - width = self.options.desktop_width - height = self.options.desktop_height - path = os.path.dirname(os.path.realpath(__file__)) - self.document = etree.parse(os.path.join(path, "seamless_pattern.svg")) - root = self.document.getroot() - root.set("id", "SVGRoot") - root.set("width", str(width) + 'px') - root.set("height", str(height) + 'px') - root.set("viewBox", "0 0 " + str(width) + " " + str(height) ) - - xpathStr = '//svg:use[@id="sampleTile"]' - sampleTile = root.xpath(xpathStr, namespaces=inkex.NSS) - if sampleTile != []: - sampleTile[0].set("transform", "translate(" + str(width * 6) + ",-" + str(height) + ")") - - - xpathStr = '//svg:use[@id="clipPathRect"]' - clipPathRect = root.xpath(xpathStr, namespaces=inkex.NSS) - if clipPathRect != []: - clipPathRect[0].set("transform", "translate(" + str((width*3)) + "," + str(height) +")") - - xpathStr = '//svg:tspan[@id="infoText"]' - infoText = root.xpath(xpathStr, namespaces=inkex.NSS) - if infoText != []: - infoText[0].text = infoText[0].text.replace("100x100", str(width) + "x" + str(height)) - - xpathStr = '//svg:use[@id="backgroundPattern"]' - backgroundPattern = root.xpath(xpathStr, namespaces=inkex.NSS) - if backgroundPattern != []: - backgroundPattern[0].set("transform", "translate(-" + str(width * 2) + ",0)") - - xpathStr = '//svg:rect[@id="cuadroPattern"]' - cuadroPattern = root.xpath(xpathStr, namespaces=inkex.NSS) - if cuadroPattern != []: - cuadroPattern[0].set("width", str(width)) - cuadroPattern[0].set("height", str(height)) - cuadroPattern[0].set("y", "-" + str(height*2)) - - xpathStr = '//svg:use[@id="cuadroPatternDisenador"]' - cuadroPatternDisenador = root.xpath(xpathStr, namespaces=inkex.NSS) - if cuadroPatternDisenador != []: - cuadroPatternDisenador[0].set("transform", "translate(" + str(width * 3) + "," + str(height) + ")") - - xpathStr = '//svg:g[@id="designZone"]' - designZone = root.xpath(xpathStr, namespaces=inkex.NSS) - if designZone != []: - designZone[0].set("transform", "translate(" + str((width*5)) + ",0)scale(" + str(((width+height)/2)/100.) + ")") - - xpathStr = '//svg:g[@id="patternResult"]' - patternResult = root.xpath(xpathStr, namespaces=inkex.NSS) - if patternResult != []: - patternResult[0].set("transform", "translate(-" + str((width * 3)) + "," + str(height) + ")") - - xpathStr = '//svg:use[@id="patternTileBackground"]' - patternTileBackground = root.xpath(xpathStr, namespaces=inkex.NSS) - if patternTileBackground != []: - patternTileBackground[0].set("transform", "matrix(3,0,0,3," + str((width * 2)) + "," + str(height * 4) + ")") - patternTileBackground[0].set("width", str(width*3)) - patternTileBackground[0].set("height", str(height*3)) - - xpathStr = '//svg:use[@id="patternGenerated"]' - patternGenerated = root.xpath(xpathStr, namespaces=inkex.NSS) - if patternGenerated != []: - patternGenerated[0].set("width", str(width)) - patternGenerated[0].set("height", str(height)) - - xpathStr = '//svg:use[@id="pattern1"]' - pattern1 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern1 != []: - pattern1[0].set("transform", "translate(" + str(-width) + "," + str(-height) + ")") - - xpathStr = '//svg:use[@id="pattern2"]' - pattern2 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern2 != []: - pattern2[0].set("transform", "translate(0," + str(-height) +")" ) - - xpathStr = '//svg:use[@id="pattern3"]' - pattern3 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern3 != []: - pattern3[0].set("transform", "translate(" + str(width) + "," + str(-height) + ")" ) - - xpathStr = '//svg:use[@id="pattern4"]' - pattern4 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern4 != []: - pattern4[0].set("transform", "translate(" + str(-width) + ",0)" ) - - xpathStr = '//svg:use[@id="pattern5"]' - pattern5 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern5 != []: - pattern5[0].set("transform", "translate(0,0)" ) - - xpathStr = '//svg:use[@id="pattern6"]' - pattern6 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern6 != []: - pattern6[0].set("transform", "translate(" + str(width) + ",0)" ) - - xpathStr = '//svg:use[@id="pattern7"]' - pattern7 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern7 != []: - pattern7[0].set("transform", "translate(" + str(-width) + "," + str(height) + ")" ) - - xpathStr = '//svg:use[@id="pattern8"]' - pattern8 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern8 != []: - pattern8[0].set("transform", "translate(0," + str(height) + ")" ) - - xpathStr = '//svg:use[@id="pattern9"]' - pattern9 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern9 != []: - pattern9[0].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) - - xpathStr = '//svg:use[@id="samplePattern1"]' - samplePattern1 = root.xpath(xpathStr, namespaces=inkex.NSS) - if samplePattern1 != []: - samplePattern1[0].set("transform", "translate(" + str(-width) + "," + str(-height) + ")") - - xpathStr = '//svg:use[@id="samplePattern2"]' - samplePattern2 = root.xpath(xpathStr, namespaces=inkex.NSS) - if samplePattern2 != []: - samplePattern2[0].set("transform", "translate(0," + str(-height) +")" ) - - xpathStr = '//svg:use[@id="samplePattern3"]' - samplePattern3 = root.xpath(xpathStr, namespaces=inkex.NSS) - if samplePattern3 != []: - samplePattern3[0].set("transform", "translate(" + str(width) + "," + str(-height) + ")" ) - - xpathStr = '//svg:use[@id="samplePattern4"]' - samplePattern4 = root.xpath(xpathStr, namespaces=inkex.NSS) - if samplePattern4 != []: - samplePattern4[0].set("transform", "translate(" + str(-width) + ",0)" ) - - xpathStr = '//svg:use[@id="samplePattern5"]' - samplePattern5 = root.xpath(xpathStr, namespaces=inkex.NSS) - if samplePattern5 != []: - samplePattern5[0].set("transform", "translate(0,0)" ) - - xpathStr = '//svg:use[@id="samplePattern6"]' - samplePattern6 = root.xpath(xpathStr, namespaces=inkex.NSS) - if samplePattern6 != []: - samplePattern6[0].set("transform", "translate(" + str(width) + ",0)" ) - - xpathStr = '//svg:use[@id="samplePattern7"]' - samplePattern7 = root.xpath(xpathStr, namespaces=inkex.NSS) - if samplePattern7 != []: - samplePattern7[0].set("transform", "translate(" + str(-width) + "," + str(height) + ")" ) - - xpathStr = '//svg:use[@id="samplePattern8"]' - samplePattern8 = root.xpath(xpathStr, namespaces=inkex.NSS) - if samplePattern8 != []: - samplePattern8[0].set("transform", "translate(0," + str(height) + ")" ) - - xpathStr = '//svg:use[@id="samplePattern9"]' - samplePattern9 = root.xpath(xpathStr, namespaces=inkex.NSS) - if samplePattern9 != []: - samplePattern9[0].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) - - xpathStr = '//svg:g[@id="patternPreview"]' - patternPreview = root.xpath(xpathStr, namespaces=inkex.NSS) - if patternPreview != []: - patternPreview[0].set("transform", "translate(0," + str(height*2) + ")" ) - - xpathStr = '//svg:g[@id="helperLayer"]' - helperLayer = root.xpath(xpathStr, namespaces=inkex.NSS) - if helperLayer != []: - helperLayer[0].set("transform", "scale(" + str(width/100.) + "," + str(height/100.) + ")" ) - - xpathStr = '//svg:rect[@id="fondoGris"]' - fondoGris = root.xpath(xpathStr, namespaces=inkex.NSS) - if fondoGris != []: - fondoGris[0].set("transform", "scale(" + str(width/100.) + "," + str(height/100.) + ")" ) - - xpathStr = '//svg:use[@id="patternGenerator" or id="patternPreviewFast"]' - patternGenerator = root.xpath(xpathStr, namespaces=inkex.NSS) - if patternGenerator != []: - patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-cx", str(width/2)) - patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-cy", str(height/2)) - patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-w", str(width)) - patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-h", str(height)) - patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-x0", str(width)) - patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-y0", str(height)) - patternGenerator[0].set("width", str(width)) - patternGenerator[0].set("height", 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'), 'px') - - namedview.set(inkex.addNS('cx', 'inkscape'), str((width*8)/2.0) ) - namedview.set(inkex.addNS('cy', 'inkscape'), "0" ) - namedview.set(inkex.addNS('zoom', 'inkscape'), str(0.5 / (((width+height)/2)/100.)) ) - -c = C() -c.affect() +#!/usr/bin/env python + +# Written by Jabiertxof +# V.04 + +import inkex +import re +import os +from lxml import etree + +class C(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("-w", "--width", action="store", type="int", dest="desktop_width", default="100", help="Custom width") + self.OptionParser.add_option("-z", "--height", action="store", type="int", dest="desktop_height", default="100", help="Custom height") + + def effect(self): + + width = self.options.desktop_width + height = self.options.desktop_height + path = os.path.dirname(os.path.realpath(__file__)) + self.document = etree.parse(os.path.join(path, "seamless_pattern.svg")) + root = self.document.getroot() + root.set("id", "SVGRoot") + root.set("width", str(width) + 'px') + root.set("height", str(height) + 'px') + root.set("viewBox", "0 0 " + str(width) + " " + str(height) ) + + xpathStr = '//svg:rect[@id="clipPathRect"]' + clipPathRect = root.xpath(xpathStr, namespaces=inkex.NSS) + if clipPathRect != []: + clipPathRect[0].set("width", str(width)) + clipPathRect[0].set("height", str(height)) + + xpathStr = '//svg:g[@id="designTop"] | //svg:g[@id="designBottom"]' + designZone = root.xpath(xpathStr, namespaces=inkex.NSS) + if designZone != []: + designZone[0].set("transform", "scale(" + str(width/100.) + ","+ str(height/100.) + ")") + designZone[1].set("transform", "scale(" + str(width/100.) + ","+ str(height/100.) + ")") + + xpathStr = '//svg:use[@id="top1"] | //svg:use[@id="bottom1"]' + pattern1 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern1 != []: + pattern1[0].set("transform", "translate(" + str(-width) + "," + str(-height) + ")") + pattern1[1].set("transform", "translate(" + str(-width) + "," + str(-height) + ")") + + xpathStr = '//svg:use[@id="top2"] | //svg:use[@id="bottom2"]' + pattern2 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern2 != []: + pattern2[0].set("transform", "translate(0," + str(-height) +")" ) + pattern2[1].set("transform", "translate(0," + str(-height) +")" ) + + xpathStr = '//svg:use[@id="top3"] | //svg:use[@id="bottom3"]' + pattern3 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern3 != []: + pattern3[0].set("transform", "translate(" + str(width) + "," + str(-height) + ")" ) + pattern3[1].set("transform", "translate(" + str(width) + "," + str(-height) + ")" ) + + xpathStr = '//svg:use[@id="top4"] | //svg:use[@id="bottom4"]' + pattern4 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern4 != []: + pattern4[0].set("transform", "translate(" + str(-width) + ",0)" ) + pattern4[1].set("transform", "translate(" + str(-width) + ",0)" ) + + xpathStr = '//svg:use[@id="top5"] | //svg:use[@id="bottom5"]' + pattern5 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern5 != []: + pattern5[0].set("transform", "translate(0,0)" ) + pattern5[1].set("transform", "translate(0,0)" ) + + xpathStr = '//svg:use[@id="top6"] | //svg:use[@id="bottom6"]' + pattern6 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern6 != []: + pattern6[0].set("transform", "translate(" + str(width) + ",0)" ) + pattern6[1].set("transform", "translate(" + str(width) + ",0)" ) + + xpathStr = '//svg:use[@id="top7"] | //svg:use[@id="bottom7"]' + pattern7 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern7 != []: + pattern7[0].set("transform", "translate(" + str(-width) + "," + str(height) + ")" ) + pattern7[1].set("transform", "translate(" + str(-width) + "," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="top8"] | //svg:use[@id="bottom8"]' + pattern8 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern8 != []: + pattern8[0].set("transform", "translate(0," + str(height) + ")" ) + pattern8[1].set("transform", "translate(0," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="top9"] | //svg:use[@id="bottom9"]' + pattern9 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern9 != []: + pattern9[0].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) + pattern9[1].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="clonePreview1"]' + clonePreview1 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview1 != []: + clonePreview1[0].set("transform", "translate(0," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="clonePreview2"]' + clonePreview2 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview2 != []: + clonePreview2[0].set("transform", "translate(0," + str(height * 2) + ")" ) + + xpathStr = '//svg:use[@id="clonePreview3"]' + clonePreview3 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview3 != []: + clonePreview3[0].set("transform", "translate(" + str(width) + ",0)" ) + + xpathStr = '//svg:use[@id="clonePreview4"]' + clonePreview4 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview4 != []: + clonePreview4[0].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="clonePreview5"]' + clonePreview5 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview5 != []: + clonePreview5[0].set("transform", "translate(" + str(width) + "," + str(height * 2) + ")" ) + + xpathStr = '//svg:use[@id="clonePreview6"]' + clonePreview6 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview6 != []: + clonePreview6[0].set("transform", "translate(" + str(width*2) + ", 0)" ) + + xpathStr = '//svg:use[@id="clonePreview7"]' + clonePreview7 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview7 != []: + clonePreview7[0].set("transform", "translate(" + str(width*2) + "," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="clonePreview8"]' + clonePreview8 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview8 != []: + clonePreview8[0].set("transform", "translate(" + str(width*2) + "," + str(height*2) + ")" ) + + xpathStr = '//svg:use[@id="fullPatternClone"]' + patternGenerator = root.xpath(xpathStr, namespaces=inkex.NSS) + if patternGenerator != []: + patternGenerator[0].set("transform", "translate(" + str(width * 2) + ",-" + str(height) + ")" ) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-cx", str(width/2)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-cy", str(height/2)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-w", str(width)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-h", str(height)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-x0", str(width)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-y0", str(height)) + patternGenerator[0].set("width", str(width)) + patternGenerator[0].set("height", 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'), 'px') + + namedview.set(inkex.addNS('cx', 'inkscape'), str((width*8)/2.0) ) + namedview.set(inkex.addNS('cy', 'inkscape'), "0" ) + namedview.set(inkex.addNS('zoom', 'inkscape'), str(0.5 / (((width+height)/2)/100.)) ) + +c = C() +c.affect() diff --git a/share/extensions/seamless_pattern.svg b/share/extensions/seamless_pattern.svg index e29b52255..1fe4fc5ec 100644 --- a/share/extensions/seamless_pattern.svg +++ b/share/extensions/seamless_pattern.svg @@ -1,14 +1,11 @@ - - + + - - - - - + + @@ -25,61 +22,53 @@ Pattern Pattern - - - - - - + + + + + + - - - - - - - - - - + + + - - - - - - - - - - - + + + + + + + + + + - - - - - Backgroundcolor - Seamless PatternExport as page - PREVIEW -export as multiple of tile size 100x100xROWSxCOLS in px Tile it with tiled clones (edit->clones->tiled clones)Or use as pattern. You can copy full patern -grey block- to use on other documents - - Draw inside - - 3x3 Simple translation example - SEAMLESS PATTERN - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + Use "design top" layer and "design bottom" layer inside the seamless pattern todesign, bottom for backgrounds and top for top draws. Go to root layer to use or convert to inkscape pattern. Use clones to sure is the correct patternFor document share patterns you need to convert to pattern the original and you can't edit later in a seamless way + Seamless pattern -- cgit v1.2.3 From 89cf10eee372c34e9b970f71d3f38ef011aebf48 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 21 Oct 2014 00:52:56 +0200 Subject: Some style changes to seamles pattern extension (bzr r13341.1.284) --- share/extensions/seamless_pattern.py | 4 ++-- share/extensions/seamless_pattern.svg | 32 ++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/seamless_pattern.py b/share/extensions/seamless_pattern.py index d04675b6b..f48de954a 100644 --- a/share/extensions/seamless_pattern.py +++ b/share/extensions/seamless_pattern.py @@ -151,9 +151,9 @@ class C(inkex.Effect): namedview.set(inkex.addNS('document-units', 'inkscape'), 'px') - namedview.set(inkex.addNS('cx', 'inkscape'), str((width*8)/2.0) ) + namedview.set(inkex.addNS('cx', 'inkscape'), str((width*5.5)/2.0) ) namedview.set(inkex.addNS('cy', 'inkscape'), "0" ) - namedview.set(inkex.addNS('zoom', 'inkscape'), str(0.5 / (((width+height)/2)/100.)) ) + namedview.set(inkex.addNS('zoom', 'inkscape'), str(1.0 / (width/100.0)) ) c = C() c.affect() diff --git a/share/extensions/seamless_pattern.svg b/share/extensions/seamless_pattern.svg index 1fe4fc5ec..7ed009394 100644 --- a/share/extensions/seamless_pattern.svg +++ b/share/extensions/seamless_pattern.svg @@ -1,9 +1,15 @@ - - + + + + + + + + @@ -18,9 +24,9 @@ - Pattern - Pattern - Pattern + Seamless Pattern + Seamless Pattern + Seamless Pattern @@ -30,8 +36,14 @@ - - + + + + @@ -64,11 +76,11 @@ - + - Use "design top" layer and "design bottom" layer inside the seamless pattern todesign, bottom for backgrounds and top for top draws. Go to root layer to use or convert to inkscape pattern. Use clones to sure is the correct patternFor document share patterns you need to convert to pattern the original and you can't edit later in a seamless way - Seamless pattern + Seamless pattern + You can use "design top" layer and "design bottom" layer inside this seamless pattern to design.Go to Patern -root- layer to use the seamless patern. -- cgit v1.2.3 From 369c45fef934314ac368eb5de8f7fe3e0631fdb0 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 27 Oct 2014 00:05:33 +0100 Subject: Little tweaks to seamless pattern procedural template (bzr r13341.1.287) --- share/extensions/seamless_pattern_procedural.inx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/seamless_pattern_procedural.inx b/share/extensions/seamless_pattern_procedural.inx index 8f11d5746..f9800c63d 100644 --- a/share/extensions/seamless_pattern_procedural.inx +++ b/share/extensions/seamless_pattern_procedural.inx @@ -13,11 +13,11 @@ - Seamless Pattern + Seamless Pattern... Jabiertxof Create seamless patterns. 2014-10-16 - seamless_patterns + live seamless patterns