diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-03-14 16:37:50 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2016-03-14 16:37:50 +0000 |
| commit | b8d22beef5345210ad27cdc2685083aeae6f8f3b (patch) | |
| tree | d69b8bfd19d3627a8425a1b265c2abf229b05354 /share/extensions | |
| parent | fixes for update to trunk (diff) | |
| parent | "Relative to" option for node alignment. (diff) | |
| download | inkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.tar.gz inkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.zip | |
update to trunk
(bzr r13708.1.39)
Diffstat (limited to 'share/extensions')
88 files changed, 1907 insertions, 4503 deletions
diff --git a/share/extensions/CMakeLists.txt b/share/extensions/CMakeLists.txt index 280abd0a7..c167a156a 100644 --- a/share/extensions/CMakeLists.txt +++ b/share/extensions/CMakeLists.txt @@ -42,8 +42,5 @@ install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/Poly3DO file(GLOB _FILES "ink2canvas/*.py") install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/ink2canvas) -file(GLOB _FILES "scour/*.py") -install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/scour) - file(GLOB _FILES "xaml2svg/*.xsl") install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/xaml2svg) diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am index 765f18a02..f247cd8bb 100644 --- a/share/extensions/Makefile.am +++ b/share/extensions/Makefile.am @@ -4,7 +4,6 @@ SUBDIRS = \ Barcode \ ink2canvas \ Poly3DObjects \ - scour \ test \ xaml2svg diff --git a/share/extensions/color_randomize.inx b/share/extensions/color_randomize.inx index 82691f0f4..0c84227ae 100644 --- a/share/extensions/color_randomize.inx +++ b/share/extensions/color_randomize.inx @@ -8,11 +8,15 @@ <param name="tab" type="notebook"> <page name="Options" _gui-text="Options"> <param name="hue" type="boolean" _gui-text="Hue">true</param> + <param name="hue_range" type="int" appearance="full" min="0" max="100" indent="0" _gui-text="Hue range (%)">100</param> <param name="saturation" type="boolean" _gui-text="Saturation">true</param> + <param name="saturation_range" type="int" appearance="full" min="0" max="100" indent="0" _gui-text="Saturation range (%)">100</param> <param name="lightness" type="boolean" _gui-text="Lightness">true</param> + <param name="lightness_range" type="int" appearance="full" min="0" max="100" indent="0" _gui-text="Lightness range (%)">100</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> + <_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. Lower the range values to limit the distance between the original color and the randomized one.</_param> </page> </param> <effect> diff --git a/share/extensions/color_randomize.py b/share/extensions/color_randomize.py index e939b7b6d..b8f52cb6b 100755..100644 --- a/share/extensions/color_randomize.py +++ b/share/extensions/color_randomize.py @@ -7,15 +7,27 @@ class C(coloreffect.ColorEffect): self.OptionParser.add_option("-x", "--hue", action="store", type="inkbool", dest="hue", default=True, - help="randomize hue") + help="Randomize hue") + self.OptionParser.add_option("-y", "--hue_range", + action="store", type="int", + dest="hue_range", default=0, + help="Hue range") self.OptionParser.add_option("-s", "--saturation", action="store", type="inkbool", dest="saturation", default=True, - help="randomize saturation") + help="Randomize saturation") + self.OptionParser.add_option("-t", "--saturation_range", + action="store", type="int", + dest="saturation_range", default=0, + help="Saturation range") self.OptionParser.add_option("-l", "--lightness", action="store", type="inkbool", dest="lightness", default=True, - help="randomize lightness") + help="Randomize lightness") + self.OptionParser.add_option("-m", "--lightness_range", + action="store", type="int", + dest="lightness_range", default=0, + help="Lightness range") self.OptionParser.add_option("--tab", action="store", type="string", dest="tab", @@ -23,12 +35,46 @@ class C(coloreffect.ColorEffect): def colmod(self,r,g,b): hsl = self.rgb_to_hsl(r/255.0, g/255.0, b/255.0) + if(self.options.hue): - hsl[0]=random.random() + limit = 255.0 * (1 + self.options.hue_range) / 100.0 + limit /= 2 + max = int((hsl[0] * 255.0) + limit) + min = int((hsl[0] * 255.0) - limit) + if max > 255: + min = min - (max - 255) + max = 255 + if min < 0: + max = max - min + min = 0 + hsl[0] = random.randrange(min, max) + hsl[0] /= 255.0 if(self.options.saturation): - hsl[1]=random.random() + limit = 255.0 * (1 + self.options.saturation_range) / 100.0 + limit /= 2 + max = int((hsl[1] * 255.0) + limit) + min = int((hsl[1] * 255.0) - limit) + if max > 255: + min = min - (max - 255) + max = 255 + if min < 0: + max = max - min + min = 0 + hsl[1] = random.randrange(min, max) + hsl[1] /= 255.0 if(self.options.lightness): - hsl[2]=random.random() + limit = 255.0 * (1 + self.options.lightness_range) / 100.0 + limit /= 2 + max = int((hsl[2] * 255.0) + limit) + min = int((hsl[2] * 255.0) - limit) + if max > 255: + min = min - (max - 255) + max = 255 + if min < 0: + max = max - min + min = 0 + hsl[2] = random.randrange(min, max) + hsl[2] /= 255.0 rgb = self.hsl_to_rgb(hsl[0], hsl[1], hsl[2]) return '%02x%02x%02x' % (rgb[0]*255, rgb[1]*255, rgb[2]*255) diff --git a/share/extensions/dia2svg.sh b/share/extensions/dia2svg.sh index 0e3155f59..86acd593e 100755 --- a/share/extensions/dia2svg.sh +++ b/share/extensions/dia2svg.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh rc=0 diff --git a/share/extensions/dm2svg.py b/share/extensions/dm2svg.py index 908fedbad..908fedbad 100644..100755 --- a/share/extensions/dm2svg.py +++ b/share/extensions/dm2svg.py diff --git a/share/extensions/dxf_input.py b/share/extensions/dxf_input.py index f0a1296f1..acfed0921 100755 --- a/share/extensions/dxf_input.py +++ b/share/extensions/dxf_input.py @@ -35,7 +35,7 @@ def export_MTEXT(): y = vals[groups['20']][0] # optional group codes : (21, 40, 50) (direction, text height mm, text angle) size = 12 # default fontsize in px - if vals[groups['40']]: + if vals[groups['40']] and vals[groups['40']][0]: size = scale*vals[groups['40']][0] attribs = {'x': '%f' % x, 'y': '%f' % y, 'style': 'font-size: %.1fpx; fill: %s; font-family: %s' % (size, color, options.font)} angle = 0 # default angle in degrees @@ -75,7 +75,7 @@ def export_POINT(): def export_LINE(): # mandatory group codes : (10, 11, 20, 21) (x1, x2, y1, y2) if vals[groups['10']] and vals[groups['11']] and vals[groups['20']] and vals[groups['21']]: - path = 'M %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], scale*(vals[groups['11']][0] - xmin), height - scale*(vals[groups['21']][0] - ymin)) + path = 'M %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], scale*(extrude*vals[groups['11']][0] - xmin), height - scale*(vals[groups['21']][0] - ymin)) attribs = {'d': path, 'style': style} inkex.etree.SubElement(layer, 'path', attribs) @@ -230,7 +230,7 @@ def export_HATCH(): i40 += 1 i72 += 1 elif vals[groups['72']][i72] == 1: # line - path += 'L %f,%f ' % (scale*(vals[groups['11']][i11] - xmin), height - scale*(vals[groups['21']][i11] - ymin)) + path += 'L %f,%f ' % (scale*(extrude*vals[groups['11']][i11] - xmin), height - scale*(vals[groups['21']][i11] - ymin)) i11 += 1 i72 += 1 i10 += 1 @@ -259,7 +259,7 @@ def export_DIMENSION(): return attribs = {'d': path, 'style': style + '; marker-start: url(#DistanceX); marker-end: url(#DistanceX); stroke-width: 0.25px'} inkex.etree.SubElement(layer, 'path', attribs) - x = scale*(vals[groups['11']][0] - xmin) + x = scale*(extrude*vals[groups['11']][0] - xmin) y = height - scale*(vals[groups['21']][0] - ymin) size = 12 # default fontsize in px if vals[groups['3']]: @@ -279,7 +279,11 @@ def export_INSERT(): if vals[groups['2']] and vals[groups['10']] and vals[groups['20']]: x = vals[groups['10']][0] + scale*xmin y = vals[groups['20']][0] - scale*ymin - height - attribs = {'x': '%f' % x, 'y': '%f' % y, inkex.addNS('href','xlink'): '#' + quote(vals[groups['2']][0].replace(" ", "_").encode("utf-8"))} + attribs = {inkex.addNS('href','xlink'): '#' + quote(vals[groups['2']][0].replace(" ", "_").encode("utf-8"))} + tform = 'translate(%f, %f)' % (x, y) + if vals[groups['41']] and vals[groups['42']]: + tform += ' scale(%f, %f)' % (vals[groups['41']][0], vals[groups['42']][0]) + attribs.update({'transform': tform}) inkex.etree.SubElement(layer, 'use', attribs) def export_BLOCK(): @@ -338,7 +342,7 @@ def get_group(group): # define DXF Entities and specify which Group Codes to monitor entities = {'MTEXT': export_MTEXT, 'TEXT': export_MTEXT, 'POINT': export_POINT, 'LINE': export_LINE, 'SPLINE': export_SPLINE, 'CIRCLE': export_CIRCLE, 'ARC': export_ARC, 'ELLIPSE': export_ELLIPSE, 'LEADER': export_LEADER, 'LWPOLYLINE': export_LWPOLYLINE, 'HATCH': export_HATCH, 'DIMENSION': export_DIMENSION, 'INSERT': export_INSERT, 'BLOCK': export_BLOCK, 'ENDBLK': export_ENDBLK, 'ATTDEF': export_ATTDEF, 'VIEWPORT': False, 'ENDSEC': False} -groups = {'1': 0, '2': 1, '3': 2, '6': 3, '8': 4, '10': 5, '11': 6, '13': 7, '14': 8, '20': 9, '21': 10, '23': 11, '24': 12, '40': 13, '41': 14, '42': 15, '50': 16, '51': 17, '62': 18, '70': 19, '72': 20, '73': 21, '92': 22, '93': 23, '370': 24} +groups = {'1': 0, '2': 1, '3': 2, '6': 3, '8': 4, '10': 5, '11': 6, '13': 7, '14': 8, '20': 9, '21': 10, '23': 11, '24': 12, '40': 13, '41': 14, '42': 15, '50': 16, '51': 17, '62': 18, '70': 19, '72': 20, '73': 21, '92': 22, '93': 23, '230': 24, '370': 25} colors = { 1: '#FF0000', 2: '#FFFF00', 3: '#00FF00', 4: '#00FFFF', 5: '#0000FF', 6: '#FF00FF', 8: '#414141', 9: '#808080', 12: '#BD0000', 30: '#FF7F00', 250: '#333333', 251: '#505050', 252: '#696969', 253: '#828282', 254: '#BEBEBE', 255: '#FFFFFF'} @@ -468,10 +472,6 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES): val = val.decode('unicode_escape') elif line[0] == '62' or line[0] == '70' or line[0] == '92' or line[0] == '93': val = int(line[1]) - elif line[0] == '10' or line[0] == '13' or line[0] == '14': # scaled float x value - val = scale*(float(line[1]) - xmin) - elif line[0] == '20' or line[0] == '23' or line[0] == '24': # scaled float y value - val = height - scale*(float(line[1]) - ymin) else: # unscaled float value val = float(line[1]) vals[groups[line[0]]].append(val) @@ -502,10 +502,26 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES): if vals[groups['6']]: # Common Linetype if linetypes.has_key(vals[groups['6']][0]): style += ';' + linetypes[vals[groups['6']][0]] + extrude = 1.0 + if vals[groups['230']]: + extrude = float(vals[groups['230']][0]) + for xgrp in ['10', '13', '14']: # scale/reflect x values + if vals[groups[xgrp]]: + for i in range (0, len(vals[groups[xgrp]])): + vals[groups[xgrp]][i] = scale*(extrude*vals[groups[xgrp]][i] - xmin) + for ygrp in ['20', '23', '24']: # scale y values + if vals[groups[ygrp]]: + for i in range (0, len(vals[groups[ygrp]])): + vals[groups[ygrp]][i] = height - scale*(vals[groups[ygrp]][i] - ymin) + if (extrude == -1.0): # reflect angles + if vals[groups['50']] and vals[groups['51']]: + temp = vals[groups['51']][0] + vals[groups['51']][0] = 180.0 - vals[groups['50']][0] + vals[groups['50']][0] = 180.0 - temp if entities[entity]: entities[entity]() entity = line[1] - vals = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]] + vals = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]] seqs = [] if polylines: diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py index 091606ba3..b7ae0ef14 100755 --- a/share/extensions/dxf_outlines.py +++ b/share/extensions/dxf_outlines.py @@ -207,16 +207,32 @@ class MyEffect(inkex.Effect): return p = cubicsuperpath.parsePath(d) elif node.tag == inkex.addNS('rect','svg'): - x = float(node.get('x')) - y = float(node.get('y')) + x = float(node.get('x', 0)) + y = float(node.get('y', 0)) width = float(node.get('width')) height = float(node.get('height')) - p = [[[x, y],[x, y],[x, y]]] - p.append([[x + width, y],[x + width, y],[x + width, y]]) - p.append([[x + width, y + height],[x + width, y + height],[x + width, y + height]]) - p.append([[x, y + height],[x, y + height],[x, y + height]]) - p.append([[x, y],[x, y],[x, y]]) - p = [p] + d = "m %s,%s %s,%s %s,%s %s,%s z" % (x, y, width, 0, 0, height, -width, 0) + p = cubicsuperpath.parsePath(d) + elif node.tag == inkex.addNS('line','svg'): + x1 = float(node.get('x1', 0)) + x2 = float(node.get('x2', 0)) + y1 = float(node.get('y1', 0)) + y2 = float(node.get('y2', 0)) + d = "M %s,%s L %s,%s" % (x1, y1, x2, y2) + p = cubicsuperpath.parsePath(d) + elif node.tag == inkex.addNS('circle','svg'): + cx = float(node.get('cx', 0)) + cy = float(node.get('cy', 0)) + r = float(node.get('r')) + d = "m %s,%s a %s,%s 0 0 1 %s,%s %s,%s 0 0 1 %s,%s z" % (cx + r, cy, r, r, -2*r, 0, r, r, 2*r, 0) + p = cubicsuperpath.parsePath(d) + elif node.tag == inkex.addNS('ellipse','svg'): + cx = float(node.get('cx', 0)) + cy = float(node.get('cy', 0)) + rx = float(node.get('rx')) + ry = float(node.get('ry')) + d = "m %s,%s a %s,%s 0 0 1 %s,%s %s,%s 0 0 1 %s,%s z" % (cx + rx, cy, rx, ry, -2*rx, 0, rx, ry, 2*rx, 0) + p = cubicsuperpath.parsePath(d) else: return trans = node.get('transform') diff --git a/share/extensions/empty_business_card.py b/share/extensions/empty_business_card.py index 586c37abc..586c37abc 100644..100755 --- a/share/extensions/empty_business_card.py +++ b/share/extensions/empty_business_card.py diff --git a/share/extensions/empty_desktop.py b/share/extensions/empty_desktop.py index 31cb35f9d..31cb35f9d 100644..100755 --- a/share/extensions/empty_desktop.py +++ b/share/extensions/empty_desktop.py diff --git a/share/extensions/empty_dvd_cover.py b/share/extensions/empty_dvd_cover.py index 1456de51d..1456de51d 100644..100755 --- a/share/extensions/empty_dvd_cover.py +++ b/share/extensions/empty_dvd_cover.py diff --git a/share/extensions/empty_generic.py b/share/extensions/empty_generic.py index 62e27d220..62e27d220 100644..100755 --- a/share/extensions/empty_generic.py +++ b/share/extensions/empty_generic.py diff --git a/share/extensions/empty_icon.py b/share/extensions/empty_icon.py index 979edbae4..979edbae4 100644..100755 --- a/share/extensions/empty_icon.py +++ b/share/extensions/empty_icon.py diff --git a/share/extensions/empty_page.py b/share/extensions/empty_page.py index 3c1f67041..3c1f67041 100644..100755 --- a/share/extensions/empty_page.py +++ b/share/extensions/empty_page.py diff --git a/share/extensions/empty_video.py b/share/extensions/empty_video.py index 4b440704c..4b440704c 100644..100755 --- a/share/extensions/empty_video.py +++ b/share/extensions/empty_video.py diff --git a/share/extensions/flatten.inx b/share/extensions/flatten.inx index 4c8298623..74b939c02 100644 --- a/share/extensions/flatten.inx +++ b/share/extensions/flatten.inx @@ -4,7 +4,7 @@ <id>org.ekips.filter.flatten</id> <dependency type="executable" location="extensions">flatten.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> - <param name="flatness" type="float" min="0.0" max="1000.0" _gui-text="Flatness:">10.0</param> + <param name="flatness" type="float" min="0.1" max="1000.0" _gui-text="Flatness:">10.0</param> <effect> <object-type>path</object-type> <effects-menu> diff --git a/share/extensions/flatten.py b/share/extensions/flatten.py index ce6915086..f5add5fc5 100755 --- a/share/extensions/flatten.py +++ b/share/extensions/flatten.py @@ -40,7 +40,7 @@ class MyEffect(inkex.Effect): cmd = 'M' first = False np.append([cmd,[csp[1][0],csp[1][1]]]) - node.set('d',simplepath.formatPath(np)) + node.set('d',simplepath.formatPath(np)) if __name__ == '__main__': e = MyEffect() diff --git a/share/extensions/foldablebox.py b/share/extensions/foldablebox.py index b504de89f..9d58974c5 100755 --- a/share/extensions/foldablebox.py +++ b/share/extensions/foldablebox.py @@ -22,6 +22,7 @@ __version__ = "0.2" import inkex, simplestyle from math import * from simplepath import formatPath +import simpletransform class FoldableBox(inkex.Effect): @@ -258,6 +259,12 @@ class FoldableBox(inkex.Effect): g.set( 'transform', 'translate(%f,%f)' % ( (docW-left_pos)/2, (docH-lower_pos)/2 ) ) + # compensate preserved transforms of parent layer + if self.current_layer.getparent() is not None: + mat = simpletransform.composeParents(self.current_layer, [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]) + simpletransform.applyTransformToNode(simpletransform.invertTransform(mat), g) + + if __name__ == '__main__': #pragma: no cover e = FoldableBox() e.affect() diff --git a/share/extensions/fractalize.inx b/share/extensions/fractalize.inx index 4893189e8..4893189e8 100755..100644 --- a/share/extensions/fractalize.inx +++ b/share/extensions/fractalize.inx diff --git a/share/extensions/generate_voronoi.py b/share/extensions/generate_voronoi.py index 4ab67dcd6..7acd1be5f 100755 --- a/share/extensions/generate_voronoi.py +++ b/share/extensions/generate_voronoi.py @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import random # local library import inkex -import simplestyle +import simplestyle, simpletransform import voronoi inkex.localize() @@ -93,17 +93,21 @@ class Pattern(inkex.Effect): if not self.options.ids: inkex.errormsg(_("Please select an object")) exit() + scale = self.unittouu('1px') # convert to document units + self.options.size *= scale + self.options.border *= scale q = {'x':0,'y':0,'width':0,'height':0} # query the bounding box of ids[0] for query in q.keys(): p = Popen('inkscape --query-%s --query-id=%s "%s"' % (query, self.options.ids[0], self.args[-1]), shell=True, stdout=PIPE, stderr=PIPE) rc = p.wait() - q[query] = float(p.stdout.read()) + q[query] = scale*float(p.stdout.read()) + mat = simpletransform.composeParents(self.selected[self.options.ids[0]], [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]) defs = self.xpathSingle('/svg:svg//svg:defs') pattern = inkex.etree.SubElement(defs ,inkex.addNS('pattern','svg')) pattern.set('id', 'Voronoi' + str(random.randint(1, 9999))) pattern.set('width', str(q['width'])) pattern.set('height', str(q['height'])) - pattern.set('patternTransform', 'translate(%s,%s)' % (q['x'], q['y'])) + pattern.set('patternTransform', 'translate(%s,%s)' % (q['x'] - mat[0][2], q['y'] - mat[1][2])) pattern.set('patternUnits', 'userSpaceOnUse') # generate random pattern of points @@ -174,7 +178,8 @@ class Pattern(inkex.Effect): if x1 or x2 or y1 or y2: path += 'M %.3f,%.3f %.3f,%.3f ' % (x1, y1, x2, y2) - attribs = {'d': path, 'style': 'stroke:#000000'} + patternstyle = {'stroke': '#000000', 'stroke-width': str(scale)} + attribs = {'d': path, 'style': simplestyle.formatStyle(patternstyle)} inkex.etree.SubElement(pattern, inkex.addNS('path', 'svg'), attribs) # link selected object to pattern diff --git a/share/extensions/grid_cartesian.py b/share/extensions/grid_cartesian.py index 23df0ff84..ae4c6b6b4 100755 --- a/share/extensions/grid_cartesian.py +++ b/share/extensions/grid_cartesian.py @@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import inkex import simplestyle, sys from math import * +from simpletransform import computePointInNode def draw_SVG_line(x1, y1, x2, y2, width, name, parent): style = { 'stroke': '#000000', 'stroke-width':str(width), 'fill': 'none' } @@ -139,8 +140,9 @@ class Grid_Polar(inkex.Effect): # Embed grid in group #Put in in the centre of the current view - t = 'translate(' + str( self.view_center[0]- xmax/2.0) + ',' + \ - str( self.view_center[1]- ymax/2.0) + ')' + view_center = computePointInNode(list(self.view_center), self.current_layer) + t = 'translate(' + str( view_center[0]- xmax/2.0) + ',' + \ + str( view_center[1]- ymax/2.0) + ')' g_attribs = {inkex.addNS('label','inkscape'):'Grid_Polar:X' + \ str( self.options.x_divs )+':Y'+str( self.options.y_divs ), 'transform':t } diff --git a/share/extensions/grid_isometric.py b/share/extensions/grid_isometric.py index 8ac407613..6202fd9e2 100755 --- a/share/extensions/grid_isometric.py +++ b/share/extensions/grid_isometric.py @@ -26,6 +26,7 @@ import inkex import simplestyle, sys from math import * +from simpletransform import computePointInNode def draw_SVG_line(x1, y1, x2, y2, width, name, parent): @@ -101,8 +102,9 @@ class Grid_Polar(inkex.Effect): #Embed grid in group #Put in in the centre of the current view - t = 'translate(' + str( self.view_center[0]- xmax/2.0) + ',' + \ - str( self.view_center[1]- ymax/2.0) + ')' + view_center = computePointInNode(list(self.view_center), self.current_layer) + t = 'translate(' + str( view_center[0]- xmax/2.0) + ',' + \ + str( view_center[1]- ymax/2.0) + ')' g_attribs = {inkex.addNS('label','inkscape'):'Grid_Polar:X' + \ str( self.options.x_divs )+':Y'+str( self.options.y_divs ), 'transform':t } diff --git a/share/extensions/grid_polar.py b/share/extensions/grid_polar.py index 17c3499cb..350b21195 100755 --- a/share/extensions/grid_polar.py +++ b/share/extensions/grid_polar.py @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import inkex import simplestyle, sys from math import * +from simpletransform import computePointInNode def draw_SVG_circle(r, cx, cy, width, fill, name, parent): style = { 'stroke': '#000000', 'stroke-width':str(width), 'fill': fill } @@ -131,7 +132,8 @@ class Grid_Polar(inkex.Effect): # Embed grid in group #Put in in the centre of the current view - t = 'translate(' + str( self.view_center[0] ) + ',' + str( self.view_center[1] ) + ')' + view_center = computePointInNode(list(self.view_center), self.current_layer) + t = 'translate(' + str( view_center[0] ) + ',' + str( view_center[1] ) + ')' g_attribs = {inkex.addNS('label','inkscape'):'Grid_Polar:R' + str( self.options.r_divs )+':A'+str( self.options.a_divs ), 'transform':t } diff --git a/share/extensions/guides_creator.py b/share/extensions/guides_creator.py index 77ece2e36..a8c7bb18a 100755 --- a/share/extensions/guides_creator.py +++ b/share/extensions/guides_creator.py @@ -297,8 +297,8 @@ class Guides_Creator(inkex.Effect): svg = self.document.getroot() # getting the width and height attributes of the canvas - width = self.unittouu(svg.get('width'))/self.unittouu('1px') - height = self.unittouu(svg.get('height'))/self.unittouu('1px') + width = self.unittouu(svg.get('width')) + height = self.unittouu(svg.get('height')) # getting edges coordinates h_orientation = '0,' + str(round(width,4)) diff --git a/share/extensions/guillotine.py b/share/extensions/guillotine.py index bd077d60a..15a0fba96 100755 --- a/share/extensions/guillotine.py +++ b/share/extensions/guillotine.py @@ -88,11 +88,11 @@ class Guillotine(inkex.Effect): for g in xpath: guide = {} (x, y) = g.attrib['position'].split(',') - if g.attrib['orientation'] == '0,1': + if g.attrib['orientation'][:2] == '0,': guide['orientation'] = 'horizontal' guide['position'] = y guides.append(guide) - elif g.attrib['orientation'] == '1,0': + elif g.attrib['orientation'][-2:] == ',0': guide['orientation'] = 'vertical' guide['position'] = x guides.append(guide) diff --git a/share/extensions/hershey.py b/share/extensions/hershey.py index 1ddabfbe0..d0b27b129 100755 --- a/share/extensions/hershey.py +++ b/share/extensions/hershey.py @@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import hersheydata #data file w/ Hershey font data import inkex import simplestyle +from simpletransform import computePointInNode Debug = False @@ -98,7 +99,8 @@ class Hershey( inkex.Effect ): w = wmax # Translate group to center of view, approximately - t = 'translate(' + str( self.view_center[0] - scale*w/2) + ',' + str( self.view_center[1] ) + ')' + view_center = computePointInNode(list(self.view_center), self.current_layer) + t = 'translate(' + str( view_center[0] - scale*w/2) + ',' + str( view_center[1] ) + ')' if scale != 1: t += ' scale(' + str(scale) + ')' g.set( 'transform',t) diff --git a/share/extensions/hersheydata.py b/share/extensions/hersheydata.py index 2b732f9f0..2b732f9f0 100755..100644 --- a/share/extensions/hersheydata.py +++ b/share/extensions/hersheydata.py diff --git a/share/extensions/hpgl_decoder.py b/share/extensions/hpgl_decoder.py index cd900202b..a54a81e81 100644 --- a/share/extensions/hpgl_decoder.py +++ b/share/extensions/hpgl_decoder.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # coding=utf-8 ''' Copyright (C) 2013 Sebastian Wüst, sebi@timewaster.de @@ -100,4 +99,4 @@ class hpglDecoder: self.oldCoordinates = (float(parameters[-2]), float(parameters[-1])) -# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99
\ No newline at end of file +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/hpgl_encoder.py b/share/extensions/hpgl_encoder.py index 83b1b7297..0e4158725 100644 --- a/share/extensions/hpgl_encoder.py +++ b/share/extensions/hpgl_encoder.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # coding=utf-8 ''' Copyright (C) 2008 Aaron Spike, aaron@ekips.org @@ -375,4 +374,4 @@ class hpglEncoder: self.lastPen = pen self.lastPoint = [command, x, y] -# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99
\ No newline at end of file +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/hpgl_input.py b/share/extensions/hpgl_input.py index a85c32b34..a85c32b34 100644..100755 --- a/share/extensions/hpgl_input.py +++ b/share/extensions/hpgl_input.py diff --git a/share/extensions/hpgl_output.inx b/share/extensions/hpgl_output.inx index 7fa900dc8..673be29bb 100644 --- a/share/extensions/hpgl_output.inx +++ b/share/extensions/hpgl_output.inx @@ -28,8 +28,8 @@ </page> <page name="overcutToolOffset" _gui-text="Plot Features "> <param name="overcut" type="float" min="0.0" max="100.0" precision="2" _gui-text="Overcut (mm):" _gui-description="The distance in mm that will be cut over the starting point of the path to prevent open paths, set to 0.0 to omit command (Default: 1.00)">1.00</param> - <param name="toolOffset" type="float" min="0.0" max="20.0" precision="2" _gui-text="Tool offset (mm):" _gui-description="The offset from the tool tip to the tool axis in mm, set to 0.0 to omit command (Default: 0.25)">0.25</param> - <param name="precut" type="boolean" _gui-text="Use precut" _gui-description="Check this to cut a small line before the real drawing starts to correctly align the tool orientation. (Default: Checked)">true</param> + <param name="toolOffset" type="float" min="0.0" max="20.0" precision="2" _gui-text="Tool (Knife) offset correction (mm):" _gui-description="The offset from the tool tip to the tool axis in mm, set to 0.0 to omit command (Default: 0.25)">0.25</param> + <param name="precut" type="boolean" _gui-text="Precut" _gui-description="Check this to cut a small line before the real drawing starts to correctly align the tool orientation. (Default: Checked)">true</param> <param name="flat" type="float" min="0.1" max="10.0" precision="1" _gui-text="Curve flatness:" _gui-description="Curves are divided into lines, this number controls how fine the curves will be reproduced, the smaller the finer (Default: '1.2')">1.2</param> <param name="autoAlign" type="boolean" _gui-text="Auto align" _gui-description="Check this to auto align the drawing to the zero point (Plus the tool offset if used). If unchecked you have to make sure that all parts of your drawing are within the document border! (Default: Checked)">true</param> </page> diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py index fc4f248af..78edba53b 100755 --- a/share/extensions/hpgl_output.py +++ b/share/extensions/hpgl_output.py @@ -41,7 +41,7 @@ class HpglOutput(inkex.Effect): self.OptionParser.add_option('--mirrorY', action='store', type='inkbool', dest='mirrorY', default='FALSE', help='Mirror Y axis') self.OptionParser.add_option('--center', action='store', type='inkbool', dest='center', default='FALSE', help='Center zero point') self.OptionParser.add_option('--overcut', action='store', type='float', dest='overcut', default=1.0, help='Overcut (mm)') - self.OptionParser.add_option('--toolOffset', action='store', type='float', dest='toolOffset', default=0.25, help='Tool offset (mm)') + self.OptionParser.add_option('--toolOffset', action='store', type='float', dest='toolOffset', default=0.25, help='Tool (Knife) offset correction (mm)') self.OptionParser.add_option('--precut', action='store', type='inkbool', dest='precut', default='TRUE', help='Use precut') self.OptionParser.add_option('--flat', action='store', type='float', dest='flat', default=1.2, help='Curve flatness') self.OptionParser.add_option('--autoAlign', action='store', type='inkbool', dest='autoAlign', default='TRUE', help='Auto align') diff --git a/share/extensions/image_attributes.inx b/share/extensions/image_attributes.inx index a353d17e5..d9ae9cefb 100644 --- a/share/extensions/image_attributes.inx +++ b/share/extensions/image_attributes.inx @@ -14,7 +14,7 @@ <_param name="basic_desc1" type="description">Render all bitmap images like in older Inskcape versions. Available options:</_param> - <param name="fix_scaling" type="boolean" _gui-text="Support non-unifom scaling">true</param> + <param name="fix_scaling" type="boolean" _gui-text="Support non-uniform scaling">true</param> <param name="fix_rendering" type="boolean" _gui-text="Render images blocky">false</param> </page> diff --git a/share/extensions/ink2canvas/canvas.py b/share/extensions/ink2canvas/canvas.py index 1f574a63e..139835f0e 100644 --- a/share/extensions/ink2canvas/canvas.py +++ b/share/extensions/ink2canvas/canvas.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python ''' Copyright (C) 2011 Karlisson Bezerra <contact@hacktoon.com> diff --git a/share/extensions/ink2canvas/svg.py b/share/extensions/ink2canvas/svg.py index 7f3769e3c..b60b2ca9f 100644 --- a/share/extensions/ink2canvas/svg.py +++ b/share/extensions/ink2canvas/svg.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python ''' Copyright (C) 2011 Karlisson Bezerra <contact@hacktoon.com> diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index 6eb229885..0fdaeea75 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -150,6 +150,9 @@ class Effect: self.OptionParser.add_option("--id", action="append", type="string", dest="ids", default=[], help="id attribute of object to manipulate") + self.OptionParser.add_option("--selected-nodes", + action="append", type="string", dest="selected_nodes", default=[], + help="id:subpath:position of selected nodes, if any")#TODO write a parser for this def effect(self): pass @@ -206,8 +209,8 @@ class Effect: if xattr and yattr: x = self.unittouu( xattr[0] + 'px' ) y = self.unittouu( yattr[0] + 'px') - doc_height = self.unittouu(self.document.getroot().get('height')) - if x and y and doc_height is not None: + doc_height = self.unittouu(self.getDocumentHeight()) + if x and y: self.view_center = (float(x), doc_height - float(y)) # FIXME: y-coordinate flip, eliminate it when it's gone in Inkscape def getselected(self): @@ -288,6 +291,30 @@ class Effect: __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} + # Fault tolerance for lazily defined SVG + def getDocumentWidth(self): + width = self.document.getroot().get('width') + if width: + return width + else: + viewbox = self.document.getroot().get('viewBox') + if viewbox: + return viewbox.split()[2] + else: + return '0' + + # Fault tolerance for lazily defined SVG + def getDocumentHeight(self): + height = self.document.getroot().get('height') + if height: + return height + else: + viewbox = self.document.getroot().get('viewBox') + if viewbox: + return viewbox.split()[3] + else: + return '0' + # Function returns the unit used for the values in SVG. # For lack of an attribute in SVG that explicitly defines what units are used for SVG coordinates, # try to calculate the unit from the SVG width and SVG viewbox. @@ -295,15 +322,15 @@ class Effect: def getDocumentUnit(self): svgunit = 'px' #default to pixels - svgwidth = self.document.getroot().get('width') + svgwidth = self.getDocumentWidth() viewboxstr = self.document.getroot().get('viewBox') - if viewboxstr and svgwidth is not None: + if viewboxstr: unitmatch = re.compile('(%s)$' % '|'.join(self.__uuconv.keys())) param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)') p = param.match(svgwidth) - u = unitmatch.search(svgwidth) - + u = unitmatch.search(svgwidth) + width = 100 #default viewboxwidth = 100 #default svgwidthunit = 'px' #default assume 'px' unit @@ -340,22 +367,19 @@ class Effect: unit = re.compile('(%s)$' % '|'.join(self.__uuconv.keys())) param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)') - if string is not None: - p = param.match(string) - u = unit.search(string) - if p: - retval = float(p.string[p.start():p.end()]) - else: - retval = 0.0 - if u: - try: - return retval * (self.__uuconv[u.string[u.start():u.end()]] / self.__uuconv[self.getDocumentUnit()]) - except KeyError: - pass - else: # default assume 'px' unit - return retval / self.__uuconv[self.getDocumentUnit()] + p = param.match(string) + u = unit.search(string) + if p: + retval = float(p.string[p.start():p.end()]) else: - retval = None + retval = 0.0 + if u: + try: + return retval * (self.__uuconv[u.string[u.start():u.end()]] / self.__uuconv[self.getDocumentUnit()]) + except KeyError: + pass + else: # default assume 'px' unit + return retval / self.__uuconv[self.getDocumentUnit()] return retval diff --git a/share/extensions/inkscape_follow_link.py b/share/extensions/inkscape_follow_link.py index bf19cb84f..bf19cb84f 100644..100755 --- a/share/extensions/inkscape_follow_link.py +++ b/share/extensions/inkscape_follow_link.py diff --git a/share/extensions/inkscape_help_faq.inx b/share/extensions/inkscape_help_faq.inx index aa2afcb2c..fda97c08b 100644 --- a/share/extensions/inkscape_help_faq.inx +++ b/share/extensions/inkscape_help_faq.inx @@ -2,9 +2,8 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>FAQ</_name>
<id>org.inkscape.help.faq</id>
- <dependency type="executable" location="extensions">launch_webbrowser.py</dependency> - <!-- i18n. Please don't translate it unless a page exists in your language -->
- <_param name="url" gui-hidden="true" type="string">http://wiki.inkscape.org/wiki/index.php/FAQ</_param>
+ <dependency type="executable" location="extensions">launch_webbrowser.py</dependency>
+ <param name="url" gui-hidden="true" type="string">https://inkscape.org/learn/faq/</param>
<effect needs-document="false">
<object-type>all</object-type>
<effects-menu hidden="true" />
diff --git a/share/extensions/interp.inx b/share/extensions/interp.inx index cd5d32343..470d5dc10 100644 --- a/share/extensions/interp.inx +++ b/share/extensions/interp.inx @@ -9,6 +9,7 @@ <param name="method" type="int" min="1" max="2" _gui-text="Interpolation method:">2</param> <param name="dup" type="boolean" _gui-text="Duplicate endpaths">true</param> <param name="style" type="boolean" _gui-text="Interpolate style">false</param> + <param name="zsort" type="boolean" _gui-text="Use Z-order" _gui-description="Workaround for reversed selection order in Live Preview cycles">false</param> <effect> <object-type>path</object-type> <effects-menu> diff --git a/share/extensions/interp.py b/share/extensions/interp.py index 459190c0e..093a98fda 100755 --- a/share/extensions/interp.py +++ b/share/extensions/interp.py @@ -16,7 +16,7 @@ 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 ''' -import inkex, cubicsuperpath, simplestyle, copy, math, bezmisc, simpletransform +import inkex, cubicsuperpath, simplestyle, copy, math, bezmisc, simpletransform, pathmodifier def numsegs(csp): return sum([len(p)-1 for p in csp]) @@ -103,6 +103,10 @@ class Interp(inkex.Effect): action="store", type="inkbool", dest="style", default=True, help="try interpolation of some style properties") + self.OptionParser.add_option("--zsort", + action="store", type="inkbool", + dest="zsort", default=False, + help="use z-order instead of selection order") def tweenstyleunit(self, property, start, end, time): # moved here so we can call 'unittouu' sp = self.unittouu(start[property]) @@ -122,7 +126,15 @@ class Interp(inkex.Effect): paths = {} styles = {} - for id in self.options.ids: + + if self.options.zsort: + # work around selection order swapping with Live Preview + sorted_ids = pathmodifier.zSort(self.document.getroot(),self.selected.keys()) + else: + # use selection order (default) + sorted_ids = self.options.ids + + for id in sorted_ids: node = self.selected[id] if node.tag ==inkex.addNS('path','svg'): paths[id] = cubicsuperpath.parsePath(node.get('d')) @@ -131,13 +143,13 @@ class Interp(inkex.Effect): if trans: simpletransform.applyTransformToPath(simpletransform.parseTransform(trans), paths[id]) else: - self.options.ids.remove(id) + sorted_ids.remove(id) - for i in range(1,len(self.options.ids)): - start = copy.deepcopy(paths[self.options.ids[i-1]]) - end = copy.deepcopy(paths[self.options.ids[i]]) - sst = copy.deepcopy(styles[self.options.ids[i-1]]) - est = copy.deepcopy(styles[self.options.ids[i]]) + for i in range(1,len(sorted_ids)): + start = copy.deepcopy(paths[sorted_ids[i-1]]) + end = copy.deepcopy(paths[sorted_ids[i]]) + sst = copy.deepcopy(styles[sorted_ids[i-1]]) + est = copy.deepcopy(styles[sorted_ids[i]]) basestyle = copy.deepcopy(sst) if basestyle.has_key('stroke-width'): basestyle['stroke-width'] = self.tweenstyleunit('stroke-width',sst,est,0) diff --git a/share/extensions/interp_att_g.inx b/share/extensions/interp_att_g.inx index 39c043519..7a0ef1d5c 100644 --- a/share/extensions/interp_att_g.inx +++ b/share/extensions/interp_att_g.inx @@ -40,6 +40,7 @@ <item>cm</item> <item>mm</item> </param> + <param name="zsort" type="boolean" _gui-text="Use Z-order" _gui-description="Workaround for reversed selection order in Live Preview cycles" gui-hidden="true">true</param> </page> <page name="Help" _gui-text="Help"> <_param name="intro" type="description">This effect applies a value for any interpolatable attribute for all elements inside the selected group or for all elements in a multiple selection.</_param> diff --git a/share/extensions/interp_att_g.py b/share/extensions/interp_att_g.py index 0798f7f58..168e7ffb0 100755 --- a/share/extensions/interp_att_g.py +++ b/share/extensions/interp_att_g.py @@ -23,6 +23,7 @@ import string # local library import inkex import simplestyle +from pathmodifier import zSort inkex.localize() @@ -58,6 +59,10 @@ class InterpAttG(inkex.Effect): action="store", type="string", dest="unit", default="color", help="Values unit.") + self.OptionParser.add_option("--zsort", + action="store", type="inkbool", + dest="zsort", default=True, + help="use z-order instead of selection order") self.OptionParser.add_option("--tab", action="store", type="string", dest="tab", @@ -116,8 +121,12 @@ class InterpAttG(inkex.Effect): return False if len( self.selected ) > 1: # multiple selection - self.collection = self.options.ids - for i in self.options.ids: + if self.options.zsort: + sorted_ids = zSort(self.document.getroot(),self.selected.keys()) + else: + sorted_ids = self.options.ids + self.collection = list(sorted_ids) + for i in sorted_ids: path = '//*[@id="%s"]' % i self.collection[self.tot_el] = self.document.xpath(path, namespaces=inkex.NSS)[0] self.tot_el += 1 diff --git a/share/extensions/jessyInk.js b/share/extensions/jessyInk.js index 74e9c0b9c..74e9c0b9c 100755..100644 --- a/share/extensions/jessyInk.js +++ b/share/extensions/jessyInk.js diff --git a/share/extensions/lindenmayer.py b/share/extensions/lindenmayer.py index 2e058f541..eb0d84328 100755 --- a/share/extensions/lindenmayer.py +++ b/share/extensions/lindenmayer.py @@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' import inkex, simplestyle, pturtle, random +from simpletransform import computePointInNode def stripme(s): return s.strip() @@ -68,7 +69,7 @@ class LSystem(inkex.Effect): return self.turtle.getPath() def __compose_path(self, string): self.turtle.pu() - self.turtle.setpos(self.view_center) + self.turtle.setpos(computePointInNode(list(self.view_center), self.current_layer)) self.turtle.pd() for c in string: if c in 'ABCDEF': diff --git a/share/extensions/measure.inx b/share/extensions/measure.inx index 8fae020e0..7a6598bc7 100644 --- a/share/extensions/measure.inx +++ b/share/extensions/measure.inx @@ -11,11 +11,36 @@ <_item msgctxt="measure extension" value="area">Area</_item> <_item msgctxt="measure extension" value="cofm">Center of Mass</_item> </param> - <param name="format" type="enum" _gui-text="Text Orientation: "> - <_item msgctxt="measure extension" value="textonpath">Text On Path</_item> - <_item msgctxt="measure extension" value="angle">Fixed Angle</_item> + <param name="format" type="notebook"> + <page name="presets" _gui-text="Text Presets"> + <param name="presetFormat" type="enum" _gui-text="Position:"> + <_item value="default">Default</_item> + <_item value="TaP_start">Text on Path, Start</_item> + <_item value="TaP_middle">Text on Path, Middle</_item> + <_item value="TaP_end">Text on Path, End</_item> + <_item value="FT_start">Fixed Text, Start of Path</_item> + <_item value="FT_bbox">Fixed Text, Center of BBox</_item> + <_item value="FT_mass">Fixed Text, Center of Mass</_item> + </param> + </page> + <page name="textonpath" _gui-text="Text on Path"> + <param name="startOffset" type="string" gui-hidden="true">custom</param> + <param name="startOffsetCustom" type="int" appearance="full" min="0" max="100" _gui-text="Offset (%)">50</param> + <param name="anchor" type="enum" _gui-text="Text anchor:"> + <_item value="start">Left</_item> + <_item value="middle">Center</_item> + <_item value="end">Right</_item> + </param> + </page> + <page name="fixedtext" _gui-text="Fixed Text"> + <param name="position" type="enum" _gui-text="Position:"> + <_item value="start">Start of Path</_item> + <_item value="center">Center of BBox</_item> + <_item value="mass">Center of Mass</_item> + </param> + <param name="angle" type="float" min="-360" max="360" _gui-text="Angle (°):">0</param> + </page> </param> - <param name="angle" type="float" min="-360" max="360" _gui-text="Angle [with Fixed Angle option only] (°):">0</param> <param name="fontsize" type="int" min="1" max="1000" _gui-text="Font size (px):">12</param> <param name="offset" type="float" min="-10000" max="10000" _gui-text="Offset (px):">-6</param> <param name="precision" type="int" min="0" max="25" _gui-text="Precision:">2</param> diff --git a/share/extensions/measure.py b/share/extensions/measure.py index e7c91feec..9fc632c2a 100755 --- a/share/extensions/measure.py +++ b/share/extensions/measure.py @@ -5,6 +5,7 @@ It adds text to the selected path containing the length in a given unit. Area and Center of Mass calculated using Green's Theorem: http://mathworld.wolfram.com/GreensTheorem.html +Copyright (C) 2015 ~suv <suv-sf@users.sf.net> Copyright (C) 2010 Alvin Penner Copyright (C) 2006 Georg Wiora Copyright (C) 2006 Nathan Hurst @@ -41,7 +42,14 @@ import cubicsuperpath import bezmisc inkex.localize() -locale.setlocale(locale.LC_ALL, '') + +# On darwin, fall back to C in cases of +# - incorrect locale IDs (see comments in bug #406662) +# - https://bugs.python.org/issue18378 +try: + locale.setlocale(locale.LC_ALL, '') +except locale.Error: + locale.setlocale(locale.LC_ALL, 'C') # third party try: @@ -130,17 +138,37 @@ class Length(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) self.OptionParser.add_option("--type", - action="store", type="string", - dest="type", default="length", + action="store", type="string", + dest="mtype", default="length", help="Type of measurement") self.OptionParser.add_option("--format", - action="store", type="string", - dest="format", default="textonpath", + action="store", type="string", + dest="mformat", default="textonpath", help="Text Orientation") + self.OptionParser.add_option("--presetFormat", + action="store", type="string", + dest="presetFormat", default="TaP_start", + help="Preset text layout") + self.OptionParser.add_option("--startOffset", + action="store", type="string", + dest="startOffset", default="custom", + help="Text Offset along Path") + self.OptionParser.add_option("--startOffsetCustom", + action="store", type="int", + dest="startOffsetCustom", default=50, + help="Text Offset along Path") + self.OptionParser.add_option("--anchor", + action="store", type="string", + dest="anchor", default="start", + help="Text Anchor") + self.OptionParser.add_option("--position", + action="store", type="string", + dest="position", default="start", + help="Text Position") self.OptionParser.add_option("--angle", - action="store", type="float", + action="store", type="float", dest="angle", default=0, - help="Angle") + help="Angle") self.OptionParser.add_option("-f", "--fontsize", action="store", type="int", dest="fontsize", default=20, @@ -175,6 +203,8 @@ class Length(inkex.Effect): help="dummy") def effect(self): + if self.options.mformat == '"presets"': + self.setPreset() # get number of digits prec = int(self.options.precision) scale = self.unittouu('1px') # convert to document units @@ -195,11 +225,11 @@ class Length(inkex.Effect): mat = simpletransform.composeParents(node, [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]) p = cubicsuperpath.parsePath(node.get('d')) simpletransform.applyTransformToPath(mat, p) - if self.options.type == "length": + if self.options.mtype == "length": slengths, stotal = csplength(p) self.group = inkex.etree.SubElement(node.getparent(),inkex.addNS('text','svg')) - elif self.options.type == "area": - stotal = csparea(p)*factor*self.options.scale + elif self.options.mtype == "area": + stotal = abs(csparea(p)*factor*self.options.scale) self.group = inkex.etree.SubElement(node.getparent(),inkex.addNS('text','svg')) else: xc, yc = cspcofm(p) @@ -209,16 +239,57 @@ class Length(inkex.Effect): continue # Format the length as string lenstr = locale.format("%(len)25."+str(prec)+"f",{'len':round(stotal*factor*self.options.scale,prec)}).strip() - if self.options.format == 'textonpath': - if self.options.type == "length": - self.addTextOnPath(self.group, 0, 0, lenstr+' '+self.options.unit, id, 'start', '50%', self.options.offset) + if self.options.mformat == '"textonpath"': + startOffset = self.options.startOffset + if startOffset == "custom": + startOffset = str(self.options.startOffsetCustom) + '%' + if self.options.mtype == "length": + self.addTextOnPath(self.group, 0, 0, lenstr+' '+self.options.unit, id, self.options.anchor, startOffset, self.options.offset) else: - self.addTextOnPath(self.group, 0, 0, lenstr+' '+self.options.unit+'^2', id, 'start', '0%', self.options.offset) - else: - if self.options.type == "length": - self.addTextWithTspan(self.group, p[0][0][1][0], p[0][0][1][1], lenstr+' '+self.options.unit, id, 'start', -int(self.options.angle), self.options.offset + self.options.fontsize/2) + self.addTextOnPath(self.group, 0, 0, lenstr+' '+self.options.unit+'^2', id, self.options.anchor, startOffset, self.options.offset) + elif self.options.mformat == '"fixedtext"': + if self.options.position == "mass": + tx, ty = cspcofm(p) + anchor = 'middle' + elif self.options.position == "center": + bbox = simpletransform.computeBBox([node]) + tx = bbox[0] + (bbox[1] - bbox[0])/2.0 + ty = bbox[2] + (bbox[3] - bbox[2])/2.0 + anchor = 'middle' + else: # default + tx = p[0][0][1][0] + ty = p[0][0][1][1] + anchor = 'start' + if self.options.mtype == "length": + self.addTextWithTspan(self.group, tx, ty, lenstr+' '+self.options.unit, id, anchor, -int(self.options.angle), self.options.offset + self.options.fontsize/2) else: - self.addTextWithTspan(self.group, p[0][0][1][0], p[0][0][1][1], lenstr+' '+self.options.unit+'^2', id, 'start', -int(self.options.angle), -self.options.offset + self.options.fontsize/2) + self.addTextWithTspan(self.group, tx, ty, lenstr+' '+self.options.unit+'^2', id, anchor, -int(self.options.angle), -self.options.offset + self.options.fontsize/2) + else: + # center of mass, no text + pass + + def setPreset(self): + # keep dict in sync with enum in INX file: + preset_dict = { + 'default_length': ['"textonpath"', "50%", "start", None, None], + 'default_area': ['"fixedtext"', None, None, "start", 0.0], + 'default_cofm': [None, None, None, None, None], + 'TaP_start': ['"textonpath"', "0%", "start", None, None], + 'TaP_middle': ['"textonpath"', "50%", "middle", None, None], + 'TaP_end': ['"textonpath"', "100%", "end", None, None], + 'FT_start': ['"fixedtext"', None, None, "start", 0.0], + 'FT_bbox': ['"fixedtext"', None, None, "center", 0.0], + 'FT_mass': ['"fixedtext"', None, None, "mass", 0.0], + } + if self.options.presetFormat == "default": + current_preset = 'default_' + self.options.mtype + else: + current_preset = self.options.presetFormat + self.options.mformat = preset_dict[current_preset][0] + self.options.startOffset = preset_dict[current_preset][1] + self.options.anchor = preset_dict[current_preset][2] + self.options.position = preset_dict[current_preset][3] + self.options.angle = preset_dict[current_preset][4] def addCross(self, node, x, y, scale): l = 3*scale # 3 pixels in document units diff --git a/share/extensions/nicechart.inx b/share/extensions/nicechart.inx new file mode 100644 index 000000000..0ebcd8fca --- /dev/null +++ b/share/extensions/nicechart.inx @@ -0,0 +1,103 @@ +<!-- + nicechart.inx + + Copyright 2011-2016 + + Christoph Sterz + Florian Weber + Maren Hachmann + + 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 3 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., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. +--> + +<inkscape-extension> + <_name>NiceCharts</_name> + <id>org.inkscape.filter.nicechart</id> + <dependency type="executable" location="extensions">nicechart.py</dependency> + <dependency type="executable" location="extensions">inkex.py</dependency> + <param name="input_sections" type="notebook"> + <page name="data_settings" _gui-text="Data"> + <param name="input_type" type="notebook"> + <page name="file" _gui-text="Data from file"> + <_param name="desc" type="description">Enter the full path to a CSV file:</_param> + <param name="filename" type="string" _gui-text="File:"></param> + <param name="delimiter" type="string" _gui-text="Delimiter:">;</param> + <param name="col_key" type="int" _gui-text="Column that contains the keys:" min="0" max="10000">0</param> + <param name="col_val" type="int" _gui-text="Column that contains the values:" min="0" max="10000">1</param> + <param name="encoding" type="string" _gui-text="File encoding (e.g. utf-8):">utf-8</param> + <param name="headings" type="boolean" _gui-text="First line contains headings">false</param> + </page> + <page name="direct_input" _gui-text="Direct input"> + <_param name="desc" type="description">Type in comma separated values:</_param> + <_param name="desc" type="description">(format like this: apples:3,bananas:5)</_param> + <param name="what" type="string" _gui-text="Data:">apples:3,bananas:5,oranges:10,pears:4</param> + </page> + </param> + </page> + <page name="description_settings" _gui-text="Labels"> + <param type="string" name="font" _gui-text="Font:">sans-serif</param> + <param type="int" name="font-size" _gui-text="Font size:" min="0" max="10000">10</param> + <param type="string" name="font-color" _gui-text="Font color:">#000000</param> + </page> + <page name="chart_settings" _gui-text="Charts"> + <param type="boolean" name="rotate" _gui-text="Draw horizontally">false</param> + <param name="bar-height" type="int" _gui-text="Bar length:" min="0" max="100000">100</param> + <param name="bar-width" type="int" _gui-text="Bar width:" min="0" max="100000">10</param> + <param name="pie-radius" type="int" _gui-text="Pie radius:" min="0" max="100000">100</param> + <param name="bar-offset" type="int" _gui-text="Bar offset:" min="0" max="100000">5</param> + <param name="stroke-width" type="float" min="0.1" max="100000.0" precision="2" _gui-text="Stroke width:">1</param> + <param name="text-offset" type="int" _gui-text="Offset between chart and labels:" min="0" max="100000">5</param> + <param name="heading-offset" type="int" _gui-text="Offset between chart and chart title:" min="-100000" max="100000">50</param> + <param name="segment-overlap" type="boolean" _gui-text="Work around aliasing effects (creates overlapping segments)">false</param> + + <param name="colors" type="enum" _gui-text="Color scheme:"> + <_item value="default">Default</_item> + <_item value="blue">Blue</_item> + <_item value="gray">Gray</_item> + <_item value="contrast">Contrast</_item> + <_item value="sap">SAP</_item> + </param> + + <param type="string" name="colors_override" _gui-text="Custom colors:"></param> + + <param type="boolean" name="reverse_colors" _gui-text="Reverse color scheme">false</param> + <param type="boolean" name="blur" _gui-text="Drop shadow">false</param> + </page> + <page name="value_settings" _gui-text="Values"> + <param type="boolean" name="show_values" _gui-text="Show values">false</param> +<!-- <param type="string" name="font" _gui-text="Font:">sans-serif</param> + <param type="int" name="font-size" _gui-text="Font size:" min="0" max="10000">10</param> + <param type="description" name="desc">Font color:</param> + <param type="string" name="font-color" _gui-text="Font color:">#000000</param> +--> + </page> + </param> + <param name="type" type="enum" _gui-text="Chart type:"> + <_item value="bar">Bar chart</_item> + <_item value="pie">Pie chart</_item> + <_item value="pie_abs">Pie chart (percentage)</_item> + <_item value="stbar">Stacked bar chart</_item> + </param> + <effect> + <object-type>all</object-type> + <effects-menu> + <submenu _name="Render"/> + </effects-menu> + </effect> + <script> + <command reldir="extensions" interpreter="python">nicechart.py</command> + </script> +</inkscape-extension> diff --git a/share/extensions/nicechart.py b/share/extensions/nicechart.py new file mode 100755 index 000000000..d4a819ccc --- /dev/null +++ b/share/extensions/nicechart.py @@ -0,0 +1,718 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# nicechart.py +# +# Copyright 2011-2016 +# +# Christoph Sterz +# Florian Weber +# Maren Hachmann +# +# 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 3 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., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +# TODO / Ideas: +# allow negative values for bar charts +# show values for stacked bar charts +# don't create a new layer for each chart, but a normal group +# correct bar height for stacked bars (it's only half as high as it should be, double) +# adjust position of heading +# use aliasing workaround for stacked bars (e.g. let the rectangles overlap) + +# Example CSV file contents: +''' +Month;1978;1979;1980;1981 +January;2;1,3;0.1;2.3 +February;6.5;2.4;1.2;6.1 +March;7.4;6.7;7.9;4.7 +April;7.7;6.4;8.2;8.9 +May;10.9;11.7;18.7;11.1 +June;12.6;14.2;14.7;14.7 +July;16.5;15.5;17.5;15.1 +August;15.9;15.4;14.6;16.6 +September;14;14.5;13.2;15.3 +October;11.9;13.9;11.5;9.2 +November;6.7;8.5;7;6.6 +December;6.4;2.2;6.3;3.5 +''' +# The extension creates one chart for a single value column in one go, +# e.g. chart all temperatures for all months of the year 1978 into one chart. +# (for this, select column 0 for labels and column 1 for values). +# "1978" etc. can be used as heading (Need not be numeric. If not used delete the heading line.) +# Month names can be used as labels +# Values can be shown, in addition to labels (doesn't work with stacked bar charts) +# Values can contain commas as decimal separator, as long as delimiter isn't comma +# Negative values are not yet supported. + + +import re +import sys +import math +import inkex + +from simplestyle import * + +#www.sapdesignguild.org/goodies/diagram_guidelines/color_palettes.html#mss +COLOUR_TABLE = { + "red": ["#460101", "#980101", "#d40000", "#f44800", "#fb8b00", "#eec73e", "#d9bb7a", "#fdd99b"], + "blue": ["#000442", "#0F1781", "#252FB7", "#3A45E1", "#656DDE", "#8A91EC"], + "gray": ["#222222", "#444444", "#666666", "#888888", "#aaaaaa", "#cccccc", "#eeeeee"], + "contrast": ["#0000FF", "#FF0000", "#00FF00", "#CF9100", "#FF00FF", "#00FFFF"], + "sap": ["#f8d753", "#5c9746", "#3e75a7", "#7a653e", "#e1662a", "#74796f", "#c4384f", + "#fff8a3", "#a9cc8f", "#b2c8d9", "#bea37a", "#f3aa79", "#b5b5a9", "#e6a5a5"] +} + +def get_color_scheme(name="default"): + return COLOUR_TABLE.get(name.lower(), COLOUR_TABLE['red']) + + +class NiceChart(inkex.Effect): + """ + Inkscape extension that can draw pie charts and bar charts + (stacked, single, horizontally or vertically) + with optional drop shadow, from a csv file or from pasted text + """ + + def __init__(self): + """ + Constructor. + Defines the "--what" option of a script. + """ + # Call the base class constructor. + inkex.Effect.__init__(self) + + # Define string option "--what" with "-w" shortcut and default chart values. + self.OptionParser.add_option('-w', '--what', action='store', + type='string', dest='what', default='22,11,67', + help='Chart Values') + + # Define string option "--type" with "-t" shortcut. + self.OptionParser.add_option("-t", "--type", action="store", + type="string", dest="type", default='', + help="Chart Type") + + # Define bool option "--blur" with "-b" shortcut. + self.OptionParser.add_option("-b", "--blur", action="store", + type="inkbool", dest="blur", default='True', + help="Blur Type") + + # Define string option "--file" with "-f" shortcut. + self.OptionParser.add_option("-f", "--filename", action="store", + type="string", dest="filename", default='', + help="Name of File") + + # Define string option "--input_type" with "-i" shortcut. + self.OptionParser.add_option("-i", "--input_type", action="store", + type="string", dest="input_type", default='file', + help="Chart Type") + + # Define string option "--delimiter" with "-d" shortcut. + self.OptionParser.add_option("-d", "--delimiter", action="store", + type="string", dest="csv_delimiter", default=';', + help="delimiter") + + # Define string option "--colors" with "-c" shortcut. + self.OptionParser.add_option("-c", "--colors", action="store", + type="string", dest="colors", default='default', + help="color-scheme") + + # Define string option "--colors_override" + self.OptionParser.add_option("", "--colors_override", action="store", + type="string", dest="colors_override", default='', + help="color-scheme-override") + + + self.OptionParser.add_option("", "--reverse_colors", action="store", + type="inkbool", dest="reverse_colors", default='False', + help="reverse color-scheme") + + self.OptionParser.add_option("-k", "--col_key", action="store", + type="int", dest="col_key", default='0', + help="column that contains the keys") + + + self.OptionParser.add_option("-v", "--col_val", action="store", + type="int", dest="col_val", default='1', + help="column that contains the values") + + self.OptionParser.add_option("", "--encoding", action="store", + type="string", dest="encoding", default='utf-8', + help="encoding of the CSV file, e.g. utf-8") + + self.OptionParser.add_option("", "--headings", action="store", + type="inkbool", dest="headings", default='False', + help="the first line of the CSV file consists of headings for the columns") + + self.OptionParser.add_option("-r", "--rotate", action="store", + type="inkbool", dest="rotate", default='False', + help="Draw barchart horizontally") + + self.OptionParser.add_option("-W", "--bar-width", action="store", + type="int", dest="bar_width", default='10', + help="width of bars") + + self.OptionParser.add_option("-p", "--pie-radius", action="store", + type="int", dest="pie_radius", default='100', + help="radius of pie-charts") + + self.OptionParser.add_option("-H", "--bar-height", action="store", + type="int", dest="bar_height", default='100', + help="height of bars") + + self.OptionParser.add_option("-O", "--bar-offset", action="store", + type="int", dest="bar_offset", default='5', + help="distance between bars") + + self.OptionParser.add_option("", "--stroke-width", action="store", + type="float", dest="stroke_width", default='1') + + self.OptionParser.add_option("-o", "--text-offset", action="store", + type="int", dest="text_offset", default='5', + help="distance between bar and descriptions") + + self.OptionParser.add_option("", "--heading-offset", action="store", + type="int", dest="heading_offset", default='50', + help="distance between chart and chart title") + + self.OptionParser.add_option("", "--segment-overlap", action="store", + type="inkbool", dest="segment_overlap", default='False', + help="work around aliasing effects by letting pie chart segments overlap") + + self.OptionParser.add_option("-F", "--font", action="store", + type="string", dest="font", default='sans-serif', + help="font of description") + + self.OptionParser.add_option("-S", "--font-size", action="store", + type="int", dest="font_size", default='10', + help="font size of description") + + self.OptionParser.add_option("-C", "--font-color", action="store", + type="string", dest="font_color", default='black', + help="font color of description") + #Dummy: + self.OptionParser.add_option("","--input_sections") + + self.OptionParser.add_option("-V", "--show_values", action="store", + type="inkbool", dest="show_values", default='False', + help="Show values in chart") + + def effect(self): + """ + Effect behaviour. + Overrides base class' method and inserts a nice looking chart into SVG document. + """ + # Get script's "--what" option value and process the data type --- i concess the if term is a little bit of magic + what = self.options.what + keys = [] + values = [] + orig_values = [] + keys_present = True + pie_abs = False + cnt = 0 + csv_file_name = self.options.filename + csv_delimiter = self.options.csv_delimiter + input_type = self.options.input_type + col_key = self.options.col_key + col_val = self.options.col_val + show_values = self.options.show_values + encoding = self.options.encoding.strip() or 'utf-8' + headings = self.options.headings + heading_offset = self.options.heading_offset + + if input_type == "\"file\"": + csv_file = open(csv_file_name, "r") + + for linenum, line in enumerate(csv_file): + value = line.decode(encoding).split(csv_delimiter) + #make sure that there is at least one value (someone may want to use it as description) + if len(value) >= 1: + # allow to parse headings as strings + if linenum == 0 and headings: + heading = value[col_val] + else: + keys.append(value[col_key]) + # replace comma decimal separator from file by colon, + # to avoid file editing for people whose programs output + # values with comma + values.append(float(value[col_val].replace(",","."))) + csv_file.close() + + elif input_type == "\"direct_input\"": + what = re.findall("([A-Z|a-z|0-9]+:[0-9]+\.?[0-9]*)", what) + for value in what: + value = value.split(":") + keys.append(value[0]) + values.append(float(value[1])) + + # warn about negative values (not yet supported) + for value in values: + if value < 0: + inkex.errormsg("Negative values are currently not supported!") + return + + # Get script's "--type" option value. + charttype = self.options.type + + if charttype == "pie_abs": + pie_abs = True + charttype = "pie" + + # Get access to main SVG document element and get its dimensions. + svg = self.document.getroot() + + # Get the page attibutes: + width = self.getUnittouu(svg.get('width')) + height = self.getUnittouu(svg.attrib['height']) + + # Create a new layer. + layer = inkex.etree.SubElement(svg, 'g') + layer.set(inkex.addNS('label', 'inkscape'), 'Chart-Layer: %s' % (what)) + layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer') + + # Check if a drop shadow should be drawn: + draw_blur = self.options.blur + + if draw_blur: + # Get defs of Document + defs = self.xpathSingle('/svg:svg//svg:defs') + if defs == None: + defs = inkex.etree.SubElement(self.document.getroot(), inkex.addNS('defs', 'svg')) + + # Create new Filter + filt = inkex.etree.SubElement(defs,inkex.addNS('filter', 'svg')) + filtId = self.uniqueId('filter') + self.filtId = 'filter:url(#%s);' % filtId + for k, v in [('id', filtId), ('height', "3"), + ('width', "3"), + ('x', '-0.5'), ('y', '-0.5')]: + filt.set(k, v) + + # Append Gaussian Blur to that Filter + fe = inkex.etree.SubElement(filt, inkex.addNS('feGaussianBlur', 'svg')) + fe.set('stdDeviation', "1.1") + + # Set Default Colors + self.options.colors_override.strip() + if len(self.options.colors_override) > 0: + colors = self.options.colors_override + else: + colors = self.options.colors + + if colors[0].isalpha(): + colors = get_color_scheme(colors) + else: + colors = re.findall("(#[0-9a-fA-F]{6})", colors) + #to be sure we create a fallback: + if len(colors) == 0: + colors = get_color_scheme() + + color_count = len(colors) + + if self.options.reverse_colors: + colors.reverse() + + # Those values should be self-explanatory: + bar_height = self.options.bar_height + bar_width = self.options.bar_width + bar_offset = self.options.bar_offset + # offset of the description in stacked-bar-charts: + # stacked_bar_text_offset=self.options.stacked_bar_text_offset + text_offset = self.options.text_offset + # prevents ugly aliasing effects between pie chart segments by overlapping + segment_overlap = self.options.segment_overlap + + # get font + font = self.options.font + font_size = self.options.font_size + font_color = self.options.font_color + + # get rotation + rotate = self.options.rotate + + pie_radius = self.options.pie_radius + stroke_width = self.options.stroke_width + + if charttype == "bar": + ######### + ###BAR### + ######### + + # iterate all values, use offset to draw the bars in different places + offset = 0 + color = 0 + + # Normalize the bars to the largest value + try: + value_max = max(values) + except ValueError: + value_max = 0.0 + + for x in range(len(values)): + orig_values.append(values[x]) + values[x] = (values[x]/value_max) * bar_height + + # Draw Single bars with their shadows + for value in values: + + # draw drop shadow, if necessary + if draw_blur: + # Create shadow element + shadow = inkex.etree.Element(inkex.addNS("rect", "svg")) + # Set chart position to center of document. Make it horizontal or vertical + if not rotate: + shadow.set('x', str(width/2 + offset + 1)) + shadow.set('y', str(height/2 - int(value) + 1)) + shadow.set("width", str(bar_width)) + shadow.set("height", str(int(value))) + else: + shadow.set('y', str(width/2 + offset + 1)) + shadow.set('x', str(height/2 + 1)) + shadow.set("height", str(bar_width)) + shadow.set("width", str(int(value))) + + # Set shadow blur (connect to filter object in xml path) + shadow.set("style", "filter:url(#filter)") + + # Create rectangle element + rect = inkex.etree.Element(inkex.addNS('rect', 'svg')) + + # Set chart position to center of document. + if not rotate: + rect.set('x', str(width/2 + offset)) + rect.set('y', str(height/2 - int(value))) + rect.set("width", str(bar_width)) + rect.set("height", str(int(value))) + else: + rect.set('y', str(width/2 + offset)) + rect.set('x', str(height/2)) + rect.set("height", str(bar_width)) + rect.set("width", str(int(value))) + + rect.set("style", "fill:" + colors[color % color_count]) + + # If keys are given, create text elements + if keys_present: + text = inkex.etree.Element(inkex.addNS('text', 'svg')) + if not rotate: #=vertical + text.set("transform", "matrix(0,-1,1,0,0,0)") + #y after rotation: + text.set("x", "-" + str(height/2 + text_offset)) + #x after rotation: + text.set("y", str(width/2 + offset + bar_width/2 + font_size/3)) + else: #=horizontal + text.set("y", str(width/2 + offset + bar_width/2 + font_size/3)) + text.set("x", str(height/2 - text_offset)) + + text.set("style", "font-size:" + str(font_size)\ + + "px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:"\ + + font + ";-inkscape-font-specification:Bitstream Charter;text-align:end;text-anchor:end;fill:"\ + + font_color) + + text.text = keys[cnt] + + # Increase Offset and Color + #offset=offset+bar_width+bar_offset + color = (color + 1) % 8 + # Connect elements together. + if draw_blur: + layer.append(shadow) + layer.append(rect) + if keys_present: + layer.append(text) + + if show_values: + vtext = inkex.etree.Element(inkex.addNS('text', 'svg')) + if not rotate: #=vertical + vtext.set("transform", "matrix(0,-1,1,0,0,0)") + #y after rotation: + vtext.set("x", "-"+str(height/2+text_offset-value-text_offset-text_offset)) + #x after rotation: + vtext.set("y", str(width/2+offset+bar_width/2+font_size/3)) + else: #=horizontal + vtext.set("y", str(width/2+offset+bar_width/2+font_size/3)) + vtext.set("x", str(height/2-text_offset+value+text_offset+text_offset)) + + vtext.set("style", "font-size:"+str(font_size)\ + + "px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:"\ + + font + ";-inkscape-font-specification:Bitstream Charter;text-align:start;text-anchor:start;fill:"\ + + font_color) + + vtext.text = str(int(orig_values[cnt])) + layer.append(vtext) + + cnt = cnt+1 + offset = offset + bar_width + bar_offset + + # set x position for heading line + if not rotate: + heading_x = width/2 # TODO: adjust + else: + heading_x = width/2 # TODO: adjust + + + elif charttype == "pie": + ######### + ###PIE### + ######### + # Iterate all values to draw the different slices + color = 0 + + # Create the shadow first (if it should be created): + if draw_blur: + shadow = inkex.etree.Element(inkex.addNS("circle", "svg")) + shadow.set('cx', str(width/2)) + shadow.set('cy', str(height/2)) + shadow.set('r', str(pie_radius)) + shadow.set("style", "filter:url(#filter);fill:#000000") + layer.append(shadow) + + + # Add a grey background circle with a light stroke + background = inkex.etree.Element(inkex.addNS("circle", "svg")) + background.set("cx", str(width/2)) + background.set("cy", str(height/2)) + background.set("r", str(pie_radius)) + background.set("style", "stroke:#ececec;fill:#f9f9f9") + layer.append(background) + + #create value sum in order to divide the slices + try: + valuesum = sum(values) + + except ValueError: + valuesum = 0 + + if pie_abs: + valuesum = 100 + + num_values = len(values) + + # Set an offsetangle + offset = 0 + + # Draw single slices + for i in range(num_values): + value = values[i] + # Calculate the PI-angles for start and end + angle = (2*3.141592) / valuesum * float(value) + start = offset + end = offset + angle + + # proper overlapping + if segment_overlap: + if i != num_values-1: + end += 0.09 # add a 5° overlap + if i == 0: + start -= 0.09 # let the first element overlap into the other direction + + #then add the slice + pieslice = inkex.etree.Element(inkex.addNS("path", "svg")) + pieslice.set(inkex.addNS('type', 'sodipodi'), 'arc') + pieslice.set(inkex.addNS('cx', 'sodipodi'), str(width/2)) + pieslice.set(inkex.addNS('cy', 'sodipodi'), str(height/2)) + pieslice.set(inkex.addNS('rx', 'sodipodi'), str(pie_radius)) + pieslice.set(inkex.addNS('ry', 'sodipodi'), str(pie_radius)) + pieslice.set(inkex.addNS('start', 'sodipodi'), str(start)) + pieslice.set(inkex.addNS('end', 'sodipodi'), str(end)) + pieslice.set("style", "fill:"+ colors[color % color_count] + ";stroke:none;fill-opacity:1") + + #If text is given, draw short paths and add the text + if keys_present: + path = inkex.etree.Element(inkex.addNS("path", "svg")) + path.set("d", "m " + + str((width/2) + pie_radius * math.cos(angle/2 + offset)) + "," + + str((height/2) + pie_radius * math.sin(angle/2 + offset)) + " " + + str((text_offset - 2) * math.cos(angle/2 + offset)) + "," + + str((text_offset - 2) * math.sin(angle/2 + offset))) + + path.set("style", "fill:none;stroke:" + + font_color + ";stroke-width:" + str(stroke_width) + + "px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1") + layer.append(path) + text = inkex.etree.Element(inkex.addNS('text', 'svg')) + text.set("x", str((width/2) + (pie_radius + text_offset) * math.cos(angle/2 + offset))) + text.set("y", str((height/2) + (pie_radius + text_offset) * math.sin(angle/2 + offset) + font_size/3)) + textstyle = "font-size:" + str(font_size) \ + + "px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:" \ + + font + ";-inkscape-font-specification:Bitstream Charter;fill:" + font_color + # check if it is right or left of the Pie + if math.cos(angle/2 + offset) > 0: + text.set("style", textstyle) + else: + text.set("style", textstyle + ";text-align:end;text-anchor:end") + text.text = keys[cnt] + if show_values: + text.text = text.text + "(" + str(values[cnt]) + + if pie_abs: + text.text = text.text + " %" + + text.text = text.text + ")" + + cnt = cnt + 1 + layer.append(text) + + # increase the rotation-offset and the colorcycle-position + offset = offset + angle + color = (color + 1) % 8 + + # append the objects to the extension-layer + layer.append(pieslice) + + # set x position for heading line + heading_x = width/2 - pie_radius # TODO: adjust + + elif charttype == "stbar": + ################# + ###STACKED BAR### + ################# + # Iterate over all values to draw the different slices + color = 0 + + #create value sum in order to divide the bars + try: + valuesum = sum(values) + except ValueError: + valuesum = 0.0 + + for value in values: + valuesum = valuesum + float(value) + + # Init offset + offset = 0 + + if draw_blur: + # Create rectangle element + shadow = inkex.etree.Element(inkex.addNS("rect", "svg")) + # Set chart position to center of document. + if not rotate: + shadow.set('x', str(width/2)) + shadow.set('y', str(height/2 - bar_height/2)) + else: + shadow.set('x', str(width/2)) + shadow.set('y', str(height/2)) + # Set rectangle properties + if not rotate: + shadow.set("width", str(bar_width)) + shadow.set("height", str(bar_height/2)) + else: + shadow.set("width",str(bar_height/2)) + shadow.set("height", str(bar_width)) + # Set shadow blur (connect to filter object in xml path) + shadow.set("style", "filter:url(#filter)") + layer.append(shadow) + + i = 0 + # Draw Single bars + for value in values: + + # Calculate the individual heights normalized on 100units + normedvalue = (bar_height / valuesum) * float(value) + + # Create rectangle element + rect = inkex.etree.Element(inkex.addNS('rect', 'svg')) + + # Set chart position to center of document. + if not rotate: + rect.set('x', str(width / 2 )) + rect.set('y', str(height / 2 - offset - normedvalue)) + else: + rect.set('x', str(width / 2 + offset )) + rect.set('y', str(height / 2 )) + # Set rectangle properties + if not rotate: + rect.set("width", str(bar_width)) + rect.set("height", str(normedvalue)) + else: + rect.set("height", str(bar_width)) + rect.set("width", str(normedvalue)) + rect.set("style", "fill:" + colors[color % color_count]) + + #If text is given, draw short paths and add the text + # TODO: apply overlap workaround for visible gaps in between + if keys_present: + if not rotate: + path = inkex.etree.Element(inkex.addNS("path", "svg")) + path.set("d","m " + str((width + bar_width)/2) + "," + + str(height/2 - offset - (normedvalue / 2)) + " " + + str(bar_width/2 + text_offset) + ",0") + path.set("style", "fill:none;stroke:" + font_color + + ";stroke-width:" + str(stroke_width) + + "px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1") + layer.append(path) + text = inkex.etree.Element(inkex.addNS('text', 'svg')) + text.set("x", str(width/2 + bar_width + text_offset + 1)) + text.set("y", str(height/ 2 - offset + font_size/3 - (normedvalue/2))) + text.set("style", "font-size:" + str(font_size) + + "px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:" + + font + ";-inkscape-font-specification:Bitstream Charter;fill:" + font_color) + text.text = keys[cnt] + cnt = cnt + 1 + layer.append(text) + else: + path = inkex.etree.Element(inkex.addNS("path", "svg")) + path.set("d","m " + str((width)/2 + offset + normedvalue/2) + "," + + str(height / 2 + bar_width/2) + " 0," + + str(bar_width/2 + (font_size * i) + text_offset)) #line + path.set("style", "fill:none;stroke:" + font_color + + ";stroke-width:" + str(stroke_width) + + "px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1") + layer.append(path) + text = inkex.etree.Element(inkex.addNS('text', 'svg')) + text.set("x", str((width)/2 + offset + normedvalue/2 - font_size/3)) + text.set("y", str((height/2) + bar_width + (font_size * (i + 1)) + text_offset)) + text.set("style", "font-size:" + str(font_size) + + "px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:" + + font + ";-inkscape-font-specification:Bitstream Charter;fill:" + font_color) + text.text = keys[color] + layer.append(text) + + # Increase Offset and Color + offset = offset + normedvalue + color = (color + 1) % 8 + + # Draw rectangle + layer.append(rect) + i += 1 + + # set x position for heading line + if not rotate: + heading_x = width/2 + offset + normedvalue # TODO: adjust + else: + heading_x = width/2 + offset + normedvalue # TODO: adjust + + if headings and input_type == "\"file\"": + headingtext = inkex.etree.Element(inkex.addNS('text', 'svg')) + headingtext.set("y", str(height/2 + heading_offset)) + headingtext.set("x", str(heading_x)) + headingtext.set("style", "font-size:" + str(font_size + 4)\ + + "px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:"\ + + font + ";-inkscape-font-specification:Bitstream Charter;text-align:end;text-anchor:end;fill:"\ + + font_color) + + headingtext.text = heading + layer.append(headingtext) + + def getUnittouu(self, param): + try: + return inkex.unittouu(param) + except AttributeError: + return self.unittouu(param) + +if __name__ == '__main__': + # Create effect instance and apply it. + effect = NiceChart() + effect.affect() diff --git a/share/extensions/perspective.py b/share/extensions/perspective.py index 044257ae8..a6ee5810b 100755 --- a/share/extensions/perspective.py +++ b/share/extensions/perspective.py @@ -32,7 +32,6 @@ import inkex import simplepath import cubicsuperpath import simpletransform -import voronoi2svg from ffgeom import * inkex.localize() @@ -139,7 +138,7 @@ class Project(inkex.Effect): csp[0] = self.project_point(csp[0],m) csp[1] = self.project_point(csp[1],m) csp[2] = self.project_point(csp[2],m) - mat = voronoi2svg.Voronoi2svg().invertTransform(mat) + mat = simpletransform.invertTransform(mat) simpletransform.applyTransformToPath(mat, p) path.set('d',cubicsuperpath.formatPath(p)) diff --git a/share/extensions/plotter.inx b/share/extensions/plotter.inx index 17b2ff185..c91857b05 100644 --- a/share/extensions/plotter.inx +++ b/share/extensions/plotter.inx @@ -49,14 +49,13 @@ <_item value="xonxoff">Software (XON/XOFF)</_item> <_item value="rtscts">Hardware (RTS/CTS)</_item> <_item value="dsrdtrrtscts">Hardware (DSR/DTR + RTS/CTS)</_item> - <_item msgctxt="Flow control" value="">None</_item> + <_item value="none">None</_item> </param> <param name="commandLanguage" type="enum" _gui-text="Command language:" _gui-description="The command language to use (Default: HPGL)"> <_item value="HPGL">HPGL</_item> <_item value="DMPL">DMPL</_item> <_item value="KNK">KNK Plotter (HPGL variant)</_item> </param> - <param name="initCommands" type="string" _gui-text="Initialization commands:" _gui-description="Commands that will be sent to the plotter before the main data stream, only use this if you know what you are doing! (Default: Empty)"></param> <param name="space" type="description"> </param> <_param name="freezeHelp" type="description">Using wrong settings can under certain circumstances cause Inkscape to freeze. Always save your work before plotting!</_param> <_param name="serialHelp" type="description">This can be a physical serial connection or a USB-to-Serial bridge. Ask your plotter manufacturer for drivers if needed.</_param> @@ -82,8 +81,8 @@ </page> <page name="misc" _gui-text="Plot Features "> <param name="overcut" type="float" min="0.0" max="100.0" precision="2" _gui-text="Overcut (mm):" _gui-description="The distance in mm that will be cut over the starting point of the path to prevent open paths, set to 0.0 to omit command (Default: 1.00)">1.00</param> - <param name="toolOffset" type="float" min="0.0" max="20.0" precision="2" _gui-text="Tool offset (mm):" _gui-description="The offset from the tool tip to the tool axis in mm, set to 0.0 to omit command (Default: 0.25)">0.25</param> - <param name="precut" type="boolean" _gui-text="Use precut" _gui-description="Check this to cut a small line before the real drawing starts to correctly align the tool orientation. (Default: Checked)">true</param> + <param name="toolOffset" type="float" min="0.0" max="20.0" precision="2" _gui-text="Tool (Knife) offset correction (mm):" _gui-description="The offset from the tool tip to the tool axis in mm, set to 0.0 to omit command (Default: 0.25)">0.25</param> + <param name="precut" type="boolean" _gui-text="Precut" _gui-description="Check this to cut a small line before the real drawing starts to correctly align the tool orientation. (Default: Checked)">true</param> <param name="flat" type="float" min="0.1" max="10.0" precision="1" _gui-text="Curve flatness:" _gui-description="Curves are divided into lines, this number controls how fine the curves will be reproduced, the smaller the finer (Default: '1.2')">1.2</param> <param name="autoAlign" type="boolean" _gui-text="Auto align" _gui-description="Check this to auto align the drawing to the zero point (Plus the tool offset if used). If unchecked you have to make sure that all parts of your drawing are within the document border! (Default: Checked)">true</param> <param name="space" type="description"> </param> diff --git a/share/extensions/plotter.py b/share/extensions/plotter.py index c0f180f60..7e34f2953 100644..100755 --- a/share/extensions/plotter.py +++ b/share/extensions/plotter.py @@ -42,7 +42,6 @@ class Plot(inkex.Effect): self.OptionParser.add_option('--serialParity', action='store', type='string', dest='serialParity', default='none', help='Serial parity') self.OptionParser.add_option('--serialFlowControl', action='store', type='string', dest='serialFlowControl', default='0', help='Flow control') self.OptionParser.add_option('--commandLanguage', action='store', type='string', dest='commandLanguage', default='hpgl', help='Command Language') - self.OptionParser.add_option('--initCommands', action='store', type='string', dest='initCommands', default='', help='Initialization commands') self.OptionParser.add_option('--resolutionX', action='store', type='float', dest='resolutionX', default=1016.0, help='Resolution X (dpi)') self.OptionParser.add_option('--resolutionY', action='store', type='float', dest='resolutionY', default=1016.0, help='Resolution Y (dpi)') self.OptionParser.add_option('--pen', action='store', type='int', dest='pen', default=1, help='Pen number') @@ -53,7 +52,7 @@ class Plot(inkex.Effect): self.OptionParser.add_option('--mirrorY', action='store', type='inkbool', dest='mirrorY', default='FALSE', help='Mirror Y axis') self.OptionParser.add_option('--center', action='store', type='inkbool', dest='center', default='FALSE', help='Center zero point') self.OptionParser.add_option('--overcut', action='store', type='float', dest='overcut', default=1.0, help='Overcut (mm)') - self.OptionParser.add_option('--toolOffset', action='store', type='float', dest='toolOffset', default=0.25, help='Tool offset (mm)') + self.OptionParser.add_option('--toolOffset', action='store', type='float', dest='toolOffset', default=0.25, help='Tool (Knife) offset correction (mm)') self.OptionParser.add_option('--precut', action='store', type='inkbool', dest='precut', default='TRUE', help='Use precut') self.OptionParser.add_option('--flat', action='store', type='float', dest='flat', default=1.2, help='Curve flatness') self.OptionParser.add_option('--autoAlign', action='store', type='inkbool', dest='autoAlign', default='TRUE', help='Auto align') @@ -203,8 +202,6 @@ class Plot(inkex.Effect): type, value, traceback = sys.exc_info() raise ValueError, ('', type, value), traceback # send data to plotter - if self.options.initCommands != '': - mySerial.write(self.options.initCommands.decode('string_escape')) mySerial.write(self.hpgl) mySerial.read(2) mySerial.close() @@ -219,7 +216,6 @@ class Plot(inkex.Effect): inkex.errormsg(' Serial parity: ' + self.options.serialParity) inkex.errormsg(' Serial Flow control: ' + self.options.serialFlowControl) inkex.errormsg(' Command language: ' + self.options.commandLanguage) - inkex.errormsg(' Initialization commands: ' + self.options.initCommands) inkex.errormsg(' Resolution X (dpi): ' + str(self.options.resolutionX)) inkex.errormsg(' Resolution Y (dpi): ' + str(self.options.resolutionY)) inkex.errormsg(' Pen number: ' + str(self.options.pen)) @@ -263,7 +259,7 @@ class Plot(inkex.Effect): inkex.errormsg(' Flatness: ' + str(debugObject.flat) + ' plotter steps') inkex.errormsg(' Tool offset flatness: ' + str(debugObject.toolOffsetFlat) + ' plotter steps') inkex.errormsg("\n" + self.options.commandLanguage + " data:\n") - inkex.errormsg(self.options.initCommands + self.hpgl) + inkex.errormsg(self.hpgl) if __name__ == '__main__': # start extension diff --git a/share/extensions/polyhedron_3d.py b/share/extensions/polyhedron_3d.py index f191d7f89..8e4a8e8e6 100755 --- a/share/extensions/polyhedron_3d.py +++ b/share/extensions/polyhedron_3d.py @@ -55,6 +55,7 @@ from math import * # local library import inkex import simplestyle +from simpletransform import computePointInNode inkex.localize() @@ -467,7 +468,8 @@ class Poly_3D(inkex.Effect): #INKSCAPE GROUP TO CONTAIN THE POLYHEDRON #Put in in the centre of the current view - poly_transform = 'translate(' + str( self.view_center[0]) + ',' + str( self.view_center[1]) + ')' + view_center = computePointInNode(list(self.view_center), self.current_layer) + poly_transform = 'translate(' + str( view_center[0]) + ',' + str( view_center[1]) + ')' if scale != 1: poly_transform += ' scale(' + str(scale) + ')' #we will put all the rotations in the object name, so it can be repeated in diff --git a/share/extensions/print_win32_vector.py b/share/extensions/print_win32_vector.py index 37c2021ac..37c2021ac 100644..100755 --- a/share/extensions/print_win32_vector.py +++ b/share/extensions/print_win32_vector.py diff --git a/share/extensions/render_alphabetsoup.py b/share/extensions/render_alphabetsoup.py index 083f03af9..a2cbcb978 100755 --- a/share/extensions/render_alphabetsoup.py +++ b/share/extensions/render_alphabetsoup.py @@ -33,6 +33,7 @@ import simplestyle import render_alphabetsoup_config import bezmisc import simplepath +import simpletransform inkex.localize() @@ -533,6 +534,12 @@ class AlphabetSoup(inkex.Effect): new.set('d', simplepath.formatPath(image)) self.current_layer.append(new) + # compensate preserved transforms of parent layer + if self.current_layer.getparent() is not None: + mat = simpletransform.composeParents(self.current_layer, [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]) + simpletransform.applyTransformToNode(simpletransform.invertTransform(mat), new) + + if __name__ == '__main__': e = AlphabetSoup() e.affect() diff --git a/share/extensions/render_barcode.py b/share/extensions/render_barcode.py index 694dcc8f3..4f1464a92 100755 --- a/share/extensions/render_barcode.py +++ b/share/extensions/render_barcode.py @@ -24,6 +24,7 @@ Barcode module provided for outside or scripting. import inkex import sys from Barcode import getBarcode +from simpletransform import computePointInNode class InsertBarcode(inkex.Effect): def __init__(self): @@ -42,7 +43,7 @@ class InsertBarcode(inkex.Effect): help="Text to print on barcode") def effect(self): - x, y = self.view_center + x, y = computePointInNode(list(self.view_center), self.current_layer) bargen = getBarcode( self.options.type, text=self.options.text, height=self.options.height, diff --git a/share/extensions/render_barcode_datamatrix.py b/share/extensions/render_barcode_datamatrix.py index 83d009db8..72ffddbe6 100755 --- a/share/extensions/render_barcode_datamatrix.py +++ b/share/extensions/render_barcode_datamatrix.py @@ -54,6 +54,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # local library import inkex import simplestyle +from simpletransform import computePointInNode inkex.localize() @@ -680,7 +681,7 @@ class DataMatrix(inkex.Effect): #INKSCAPE GROUP TO CONTAIN EVERYTHING - centre = self.view_center #Put in in the centre of the current view + centre = tuple(computePointInNode(list(self.view_center), self.current_layer)) #Put in in the centre of the current view grp_transform = 'translate' + str( centre ) + ' scale(%f)' % scale grp_name = 'DataMatrix' grp_attribs = {inkex.addNS('label','inkscape'):grp_name, diff --git a/share/extensions/render_barcode_qrcode.py b/share/extensions/render_barcode_qrcode.py index 7b4895195..d4cffd3e2 100755 --- a/share/extensions/render_barcode_qrcode.py +++ b/share/extensions/render_barcode_qrcode.py @@ -2,6 +2,7 @@ import math, sys import inkex +from simpletransform import computePointInNode inkex.localize() @@ -1057,7 +1058,7 @@ class QRCodeInkscape(inkex.Effect): #INKSCAPE GROUP TO CONTAIN EVERYTHING so.TEXT = unicode(so.TEXT, so.input_encode) - centre = self.view_center #Put in in the centre of the current view + centre = tuple(computePointInNode(list(self.view_center), self.current_layer)) #Put in in the centre of the current view grp_transform = 'translate' + str( centre ) + ' scale(%f)' % scale grp_name = 'QR Code: '+so.TEXT grp_attribs = {inkex.addNS('label','inkscape'):grp_name, diff --git a/share/extensions/render_gear_rack.py b/share/extensions/render_gear_rack.py index 68c5d050e..63433aadb 100644..100755 --- a/share/extensions/render_gear_rack.py +++ b/share/extensions/render_gear_rack.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#!/usr/bin/env python ''' Copyright (C) 2013 Brett Graham (hahahaha @ hahaha.org) @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import inkex import simplestyle +from simpletransform import computePointInNode from math import * @@ -85,8 +86,9 @@ class RackGear(inkex.Effect): # Embed gear in group to make animation easier: # Translate group, Rotate path. - t = 'translate(' + str(self.view_center[0]) + ',' + \ - str(self.view_center[1]) + ')' + view_center = computePointInNode(list(self.view_center), self.current_layer) + t = 'translate(' + str(view_center[0]) + ',' + \ + str(view_center[1]) + ')' g_attribs = { inkex.addNS('label', 'inkscape'): 'RackGear' + str(length), 'transform': t} diff --git a/share/extensions/render_gears.py b/share/extensions/render_gears.py index 5fdb0d4f6..2584117f2 100644..100755 --- a/share/extensions/render_gears.py +++ b/share/extensions/render_gears.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#!/usr/bin/env python ''' Copyright (C) 2007 Aaron Spike (aaron @ ekips.org) Copyright (C) 2007 Tavmjong Bah (tavmjong @ free.fr) @@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import inkex import simplestyle, sys +from simpletransform import computePointInNode from math import * import string @@ -158,7 +159,8 @@ class Gears(inkex.Effect): # Embed gear in group to make animation easier: # Translate group, Rotate path. - t = 'translate(' + str( self.view_center[0] ) + ',' + str( self.view_center[1] ) + ')' + view_center = computePointInNode(list(self.view_center), self.current_layer) + t = 'translate(' + str( view_center[0] ) + ',' + str( view_center[1] ) + ')' g_attribs = {inkex.addNS('label','inkscape'):'Gear' + str( teeth ), 'transform':t } g = inkex.etree.SubElement(self.current_layer, 'g', g_attribs) diff --git a/share/extensions/restack.inx b/share/extensions/restack.inx index 67f0f777a..4f5f577cb 100644 --- a/share/extensions/restack.inx +++ b/share/extensions/restack.inx @@ -4,25 +4,49 @@ <id>org.inkscape.filter.restack</id> <dependency type="executable" location="extensions">restack.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> - <param name="direction" type="enum" _gui-text="Restack Direction:"> - <_item value="lr">Left to Right (0)</_item> - <_item value="bt">Bottom to Top (90)</_item> - <_item value="rl">Right to Left (180)</_item> - <_item value="tb">Top to Bottom (270)</_item> - <_item value="ro">Radial Outward</_item> - <_item value="ri">Radial Inward</_item> - <_item value="aa">Arbitrary Angle</_item> - </param> - <param name="angle" type="float" min="0.0" max="360.0" _gui-text="Angle:">0.00</param> - <param name="xanchor" type="enum" _gui-text="Horizontal Point:"> - <_item value="l">Left</_item> - <_item value="m">Middle</_item> - <_item value="r">Right</_item> - </param> - <param name="yanchor" type="enum" _gui-text="Vertical Point:"> - <_item value="t">Top</_item> - <_item value="m">Middle</_item> - <_item value="b">Bottom</_item> + <param name="tab" type="notebook"> + <page name="positional" _gui-text="Based on Position"> + <_param name="desc_dir" type="description" appearance="header">Restack Direction</_param> + <param name="nb_direction" type="notebook"> + <page name="presets" _gui-text="Presets"> + <param name="direction" type="enum" _gui-text=""> + <_item value="lr">Left to Right (0)</_item> + <_item value="bt">Bottom to Top (90)</_item> + <_item value="rl">Right to Left (180)</_item> + <_item value="tb">Top to Bottom (270)</_item> + <_item value="ro">Radial Outward</_item> + <_item value="ri">Radial Inward</_item> + </param> + </page> + <page name="custom" _gui-text="Custom"> + <param name="angle" type="float" min="0.0" max="360.0" _gui-text="Angle:">0.00</param> + </page> + </param> + <_param name="desc_ref" type="description" appearance="header">Object Reference Point</_param> + <param name="xanchor" type="enum" _gui-text="Horizontal:"> + <_item value="l">Left</_item> + <_item value="m">Middle</_item> + <_item value="r">Right</_item> + </param> + <param name="yanchor" type="enum" _gui-text="Vertical:"> + <_item value="t">Top</_item> + <_item value="m">Middle</_item> + <_item value="b">Bottom</_item> + </param> + </page> + <page name="z_order" _gui-text="Based on Z-Order"> + <_param name="desc_zsort" type="description" appearance="header">Restack Mode</_param> + <param name="zsort" type="enum" _gui-text=""> + <_item value="rev">Reverse Z-Order</_item> + <_item value="rand">Shuffle Z-Order</_item> + </param> + </page> + <page name="help" _gui-text="Help"> + <_param name="desc_help" type="description">This extension changes the z-order of objects based on their position on the canvas or their current z-order. + +Selection: +The extension restacks either objects inside a single selected group, or a selection of multiple objects on the current drawing level (layer or group).</_param> + </page> </param> <effect> <object-type>path</object-type> diff --git a/share/extensions/restack.py b/share/extensions/restack.py index 507353025..67d738a13 100755 --- a/share/extensions/restack.py +++ b/share/extensions/restack.py @@ -21,7 +21,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -import inkex, os, csv, math +import inkex, os, csv, math, random +from pathmodifier import zSort + +inkex.localize() try: from subprocess import Popen, PIPE @@ -48,107 +51,164 @@ class Restack(inkex.Effect): action="store", type="string", dest="yanchor", default="m", help="vertical point to compare") + self.OptionParser.add_option("--zsort", + action="store", type="string", + dest="zsort", default="rev", + help="Restack mode based on Z-Order") + self.OptionParser.add_option("--tab", + action="store", type="string", + dest="tab", + help="The selected UI-tab when OK was pressed") + self.OptionParser.add_option("--nb_direction", + action="store", type="string", + dest="nb_direction", + help="The selected UI-tab when OK was pressed") + def effect(self): - if len( self.selected ) > 0: - objlist = [] - svg = self.document.getroot() + if self.options.tab == '"help"': + pass + elif len(self.selected) > 0: + if self.options.tab == '"positional"': + self.restack_positional() + elif self.options.tab == '"z_order"': + self.restack_z_order() + else: + inkex.errormsg(_("There is no selection to restack.")) + + def restack_positional(self): + objects = {} + objlist = [] + file = self.args[ -1 ] + + if self.options.nb_direction == '"custom"': + self.options.direction = "aa" + + # process selection to get list of objects to be arranged + firstobject = self.selected[self.options.ids[0]] + if len(self.selected) == 1 and firstobject.tag == inkex.addNS('g', 'svg'): + parentnode = firstobject + for child in parentnode.iterchildren(): + objects[child.get('id')] = child + else: parentnode = self.current_layer - file = self.args[ -1 ] - - #get all bounding boxes in file by calling inkscape again with the --query-all command line option - #it returns a comma separated list structured id,x,y,w,h - if bsubprocess: - p = Popen('inkscape --query-all "%s"' % (file), shell=True, stdout=PIPE, stderr=PIPE) - err = p.stderr - f = p.communicate()[0] - try: - reader=csv.CSVParser().parse_string(f) #there was a module cvs.py in earlier inkscape that behaved differently - except: - reader=csv.reader(f.split( os.linesep )) - err.close() - else: - _,f,err = os.popen3('inkscape --query-all "%s"' % ( file ) ) - reader=csv.reader( f ) - err.close() - - #build a dictionary with id as the key - dimen = dict() - for line in reader: - if len(line) > 0: - dimen[line[0]] = map( float, line[1:]) - - if not bsubprocess: #close file if opened using os.popen3 - f.close - - #find the center of all selected objects **Not the average! - x,y,w,h = dimen[self.selected.keys()[0]] - minx = x - miny = y - maxx = x + w - maxy = y + h - - for id, node in self.selected.iteritems(): - # get the bounding box - x,y,w,h = dimen[id] - if x < minx: - minx = x - if (x + w) > maxx: - maxx = x + w - if y < miny: - miny = y - if (y + h) > maxy: - maxy = y + h - - midx = (minx + maxx) / 2 - midy = (miny + maxy) / 2 - - #calculate distances for each selected object - for id, node in self.selected.iteritems(): - # get the bounding box - x,y,w,h = dimen[id] - - # calc the comparison coords - if self.options.xanchor == "l": - cx = x - elif self.options.xanchor == "r": - cx = x + w - else: # middle - cx = x + w / 2 - - if self.options.yanchor == "t": - cy = y - elif self.options.yanchor == "b": - cy = y + h - else: # middle - cy = y + h / 2 - - #direction chosen - if self.options.direction == "tb" or (self.options.direction == "aa" and self.options.angle == 270): - objlist.append([cy,id]) - elif self.options.direction == "bt" or (self.options.direction == "aa" and self.options.angle == 90): - objlist.append([-cy,id]) - elif self.options.direction == "lr" or (self.options.direction == "aa" and (self.options.angle == 0 or self.options.angle == 360)): - objlist.append([cx,id]) - elif self.options.direction == "rl" or (self.options.direction == "aa" and self.options.angle == 180): - objlist.append([-cx,id]) - elif self.options.direction == "aa": - distance = math.hypot(cx,cy)*(math.cos(math.radians(-self.options.angle)-math.atan2(cy, cx))) - objlist.append([distance,id]) - elif self.options.direction == "ro": - distance = math.hypot(midx - cx, midy - cy) - objlist.append([distance,id]) - elif self.options.direction == "ri": - distance = -math.hypot(midx - cx, midy - cy) - objlist.append([distance,id]) - - objlist.sort() - #move them to the top of the object stack in this order. - for item in objlist: - parentnode.append( self.selected[item[1]]) + objects = self.selected + + #get all bounding boxes in file by calling inkscape again with the --query-all command line option + #it returns a comma separated list structured id,x,y,w,h + if bsubprocess: + p = Popen('inkscape --query-all "%s"' % (file), shell=True, stdout=PIPE, stderr=PIPE) + err = p.stderr + f = p.communicate()[0] + try: + reader=csv.CSVParser().parse_string(f) #there was a module cvs.py in earlier inkscape that behaved differently + except: + reader=csv.reader(f.split( os.linesep )) + err.close() + else: + _,f,err = os.popen3('inkscape --query-all "%s"' % ( file ) ) + reader=csv.reader( f ) + err.close() + + #build a dictionary with id as the key + dimen = dict() + for line in reader: + if len(line) > 0: + dimen[line[0]] = map( float, line[1:]) + + if not bsubprocess: #close file if opened using os.popen3 + f.close + + #find the center of all selected objects **Not the average! + x,y,w,h = dimen[objects.keys()[0]] + minx = x + miny = y + maxx = x + w + maxy = y + h + + for id, node in objects.iteritems(): + # get the bounding box + x,y,w,h = dimen[id] + if x < minx: + minx = x + if (x + w) > maxx: + maxx = x + w + if y < miny: + miny = y + if (y + h) > maxy: + maxy = y + h + + midx = (minx + maxx) / 2 + midy = (miny + maxy) / 2 + + #calculate distances for each selected object + for id, node in objects.iteritems(): + # get the bounding box + x,y,w,h = dimen[id] + + # calc the comparison coords + if self.options.xanchor == "l": + cx = x + elif self.options.xanchor == "r": + cx = x + w + else: # middle + cx = x + w / 2 + + if self.options.yanchor == "t": + cy = y + elif self.options.yanchor == "b": + cy = y + h + else: # middle + cy = y + h / 2 + + #direction chosen + if self.options.direction == "tb" or (self.options.direction == "aa" and self.options.angle == 270): + objlist.append([cy,id]) + elif self.options.direction == "bt" or (self.options.direction == "aa" and self.options.angle == 90): + objlist.append([-cy,id]) + elif self.options.direction == "lr" or (self.options.direction == "aa" and (self.options.angle == 0 or self.options.angle == 360)): + objlist.append([cx,id]) + elif self.options.direction == "rl" or (self.options.direction == "aa" and self.options.angle == 180): + objlist.append([-cx,id]) + elif self.options.direction == "aa": + distance = math.hypot(cx,cy)*(math.cos(math.radians(-self.options.angle)-math.atan2(cy, cx))) + objlist.append([distance,id]) + elif self.options.direction == "ro": + distance = math.hypot(midx - cx, midy - cy) + objlist.append([distance,id]) + elif self.options.direction == "ri": + distance = -math.hypot(midx - cx, midy - cy) + objlist.append([distance,id]) + + objlist.sort() + #move them to the top of the object stack in this order. + for item in objlist: + parentnode.append( objects[item[1]]) + + def restack_z_order(self): + parentnode = None + objects = [] + if len(self.selected) == 1: + firstobject = self.selected[self.options.ids[0]] + if firstobject.tag == inkex.addNS('g', 'svg'): + parentnode = firstobject + for child in parentnode.iterchildren(reversed=False): + objects.append(child) + else: + parentnode = self.current_layer + for id_ in zSort(self.document.getroot(), self.selected.keys()): + objects.append(self.selected[id_]) + if self.options.zsort == "rev": + objects.reverse() + elif self.options.zsort == "rand": + random.shuffle(objects) + if parentnode is not None: + for item in objects: + parentnode.append(item) + if __name__ == '__main__': e = Restack() e.affect() -# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99 +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/rtree.inx b/share/extensions/rtree.inx index 5fcac5560..8f6baee7d 100644 --- a/share/extensions/rtree.inx +++ b/share/extensions/rtree.inx @@ -6,6 +6,7 @@ <dependency type="executable" location="extensions">inkex.py</dependency> <param name="size" type="float" min="0.0" max="1000.0" _gui-text="Initial size:">100.0</param> <param name="minimum" type="float" min="0.0" max="500.0" _gui-text="Minimum size:">40.0</param> + <param name="pentoggle" type="boolean" _gui-text="Omit redundant segments" _gui-description="Lift pen for backward steps">false</param> <effect> <object-type>all</object-type> <effects-menu> diff --git a/share/extensions/rtree.py b/share/extensions/rtree.py index db677d0d5..c0dc1cca6 100755 --- a/share/extensions/rtree.py +++ b/share/extensions/rtree.py @@ -1,6 +1,7 @@ #!/usr/bin/env python ''' Copyright (C) 2005 Aaron Spike, aaron@ekips.org +Copyright (C) 2015 su_v, suv-sf@users.sf.net 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 @@ -17,20 +18,25 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' import inkex, simplestyle, pturtle, random +from simpletransform import computePointInNode -def rtree(turtle, size, min): +def rtree(turtle, size, min, pt=False): if size < min: return turtle.fd(size) turn = random.uniform(20, 40) turtle.lt(turn) - rtree(turtle, size*random.uniform(0.5,0.9), min) + rtree(turtle, size*random.uniform(0.5,0.9), min, pt) turtle.rt(turn) turn = random.uniform(20, 40) turtle.rt(turn) - rtree(turtle, size*random.uniform(0.5,0.9), min) + rtree(turtle, size*random.uniform(0.5,0.9), min, pt) turtle.lt(turn) + if pt: + turtle.pu() turtle.bk(size) + if pt: + turtle.pd() class RTreeTurtle(inkex.Effect): def __init__(self): @@ -43,6 +49,10 @@ class RTreeTurtle(inkex.Effect): action="store", type="float", dest="minimum", default=4.0, help="minimum branch size") + self.OptionParser.add_option("--pentoggle", + action="store", type="inkbool", + dest="pentoggle", default=False, + help="Lift pen for backward steps") def effect(self): self.options.size = self.unittouu(str(self.options.size) + 'px') self.options.minimum = self.unittouu(str(self.options.minimum) + 'px') @@ -52,9 +62,9 @@ class RTreeTurtle(inkex.Effect): 'fill': 'none'} t = pturtle.pTurtle() t.pu() - t.setpos(self.view_center) + t.setpos(computePointInNode(list(self.view_center), self.current_layer)) t.pd() - rtree(t, self.options.size, self.options.minimum) + rtree(t, self.options.size, self.options.minimum, self.options.pentoggle) attribs = {'d':t.getPath(),'style':simplestyle.formatStyle(s)} inkex.etree.SubElement(self.current_layer, inkex.addNS('path','svg'), attribs) diff --git a/share/extensions/scour.inkscape.py b/share/extensions/scour.inkscape.py new file mode 100755 index 000000000..eb31f308f --- /dev/null +++ b/share/extensions/scour.inkscape.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import sys, platform, inkex + +try: + import scour + from scour.scour import scourString +except Exception as e: + inkex.errormsg("Failed to import Python module 'scour'.\nPlease make sure it is installed (e.g. using 'pip install scour' or 'sudo apt-get install python-scour') and try again.") + inkex.errormsg("\nDetails:\n" + str(e)) + sys.exit() + +try: + import six +except Exception as e: + inkex.errormsg("Failed to import Python module 'six'.\nPlease make sure it is installed (e.g. using 'pip install six' or 'sudo apt-get install python-six') and try again.") + inkex.errormsg("\nDetails:\n" + str(e)) + sys.exit() + +class ScourInkscape (inkex.Effect): + + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("--tab", type="string", action="store", dest="tab") + self.OptionParser.add_option("--simplify-colors", type="inkbool", action="store", dest="simple_colors") + self.OptionParser.add_option("--style-to-xml", type="inkbool", action="store", dest="style_to_xml") + self.OptionParser.add_option("--group-collapsing", type="inkbool", action="store", dest="group_collapse") + self.OptionParser.add_option("--create-groups", type="inkbool", action="store", dest="group_create") + self.OptionParser.add_option("--enable-id-stripping", type="inkbool", action="store", dest="strip_ids") + self.OptionParser.add_option("--shorten-ids", type="inkbool", action="store", dest="shorten_ids") + self.OptionParser.add_option("--shorten-ids-prefix", type="string", action="store", dest="shorten_ids_prefix", default="") + self.OptionParser.add_option("--embed-rasters", type="inkbool", action="store", dest="embed_rasters") + self.OptionParser.add_option("--keep-unreferenced-defs", type="inkbool", action="store", dest="keep_defs") + self.OptionParser.add_option("--keep-editor-data", type="inkbool", action="store", dest="keep_editor_data") + self.OptionParser.add_option("--remove-metadata", type="inkbool", action="store", dest="remove_metadata") + self.OptionParser.add_option("--strip-xml-prolog", type="inkbool", action="store", dest="strip_xml_prolog") + self.OptionParser.add_option("--set-precision", type=int, action="store", dest="digits") + self.OptionParser.add_option("--indent", type="string", action="store", dest="indent_type") + self.OptionParser.add_option("--nindent", type=int, action="store", dest="indent_depth") + self.OptionParser.add_option("--line-breaks", type="inkbool", action="store", dest="newlines") + self.OptionParser.add_option("--strip-xml-space", type="inkbool", action="store", dest="strip_xml_space_attribute") + self.OptionParser.add_option("--protect-ids-noninkscape", type="inkbool", action="store", dest="protect_ids_noninkscape") + self.OptionParser.add_option("--protect-ids-list", type="string", action="store", dest="protect_ids_list") + self.OptionParser.add_option("--protect-ids-prefix", type="string", action="store", dest="protect_ids_prefix") + self.OptionParser.add_option("--enable-viewboxing", type="inkbool", action="store", dest="enable_viewboxing") + self.OptionParser.add_option("--enable-comment-stripping", type="inkbool", action="store", dest="strip_comments") + self.OptionParser.add_option("--renderer-workaround", type="inkbool", action="store", dest="renderer_workaround") + + def effect(self): + try: + input = file(self.args[0], "r") + self.options.infilename = self.args[0] + sys.stdout.write(scourString(input.read(), self.options).encode("UTF-8")) + input.close() + sys.stdout.close() + except Exception as e: + inkex.errormsg("Error during optimization.") + inkex.errormsg("\nDetails:\n" + str(e)) + inkex.errormsg("\nOS version: " + platform.platform()) + inkex.errormsg("Python version: " + sys.version) + inkex.errormsg("Scour version: " + scour.__version__) + sys.exit() + +if __name__ == '__main__': + e = ScourInkscape() + e.affect(output=False) diff --git a/share/extensions/scour.inx b/share/extensions/scour.inx index c97eec502..f7b8aedf7 100644 --- a/share/extensions/scour.inx +++ b/share/extensions/scour.inx @@ -2,60 +2,97 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>Optimized SVG Output</_name> <id>org.inkscape.output.scour</id> - <dependency type="executable" location="extensions">scour/scour.py</dependency> - <dependency type="executable" location="extensions">scour/svg_regex.py</dependency> - <dependency type="executable" location="extensions">scour/yocto_css.py</dependency> + <dependency type="executable" location="extensions">scour.inkscape.py</dependency> <param name="tab" type="notebook"> - <page name="Options" _gui-text="Options"> - <param name="simplify-colors" type="boolean" _gui-text="Shorten color values">true</param> - <param name="style-to-xml" type="boolean" _gui-text="Convert CSS attributes to XML attributes">true</param> - <param name="group-collapsing" type="boolean" _gui-text="Group collapsing">true</param> - <param name="create-groups" type="boolean" _gui-text="Create groups for similar attributes">true</param> - <param name="embed-rasters" type="boolean" _gui-text="Embed rasters">true</param> - <param name="keep-editor-data" type="boolean" _gui-text="Keep editor data">false</param> - <param name="remove-metadata" type="boolean" _gui-text="Remove metadata">false</param> - <param name="enable-comment-stripping" type="boolean" _gui-text="Remove comments">false</param> - <param name="renderer-workaround" type="boolean" _gui-text="Work around renderer bugs">true</param> - <param name="enable-viewboxing" type="boolean" _gui-text="Enable viewboxing">false</param> - <param name="strip-xml-prolog" type="boolean" _gui-text="Remove the xml declaration">false</param> - <param name="set-precision" type="int" _gui-text="Number of significant digits for coords:">5</param> - <param name="indent" type="enum" _gui-text="XML indentation (pretty-printing):"> + <page name="Options" _gui-text="Options"> + <param _gui-text="Number of significant digits for coordinates:" + _gui-description="Specifies the number of significant digits that should be output for coordinates. Note that significant digits are *not* the number of decimals but the overall number of digits in the output. For example if a value of "3" is specified, the coordinate 3.14159 is output as 3.14 while the coordinate 123.675 is output as 124." + name="set-precision" type="int">5</param> + <param name="spacer" type="description"> </param> + <param _gui-text="Shorten color values" + _gui-description="Convert all color specifications to #RRGGBB (or #RGB where applicable) format." + name="simplify-colors" type="boolean">true</param> + <param _gui-text="Convert CSS attributes to XML attributes" + _gui-description="Convert styles from style tags and inline style="" declarations into XML attributes." + name="style-to-xml" type="boolean">true</param> + <param name="spacer" type="description"> </param> + <param _gui-text="Collapse groups" + _gui-description="Remove useless groups, promoting their contents up one level. Requires "Remove unused IDs" to be set." + name="group-collapsing" type="boolean">true</param> + <param _gui-text="Create groups for similar attributes" + _gui-description="Create groups for runs of elements having at least one attribute in common (e.g. fill-color, stroke-opacity, ...)." + name="create-groups" type="boolean">true</param> + <param name="spacer" type="description"> </param> + <param _gui-text="Keep editor data" + _gui-description="Don't remove editor-specific elements and attributes. Currently supported: Inkscape, Sodipodi and Adobe Illustrator." + name="keep-editor-data" type="boolean">false</param> + <param _gui-text="Keep unreferenced definitions" + _gui-description="Keep element definitions that are not currently used in the SVG" + name="keep-unreferenced-defs" type="boolean">false</param> + <param name="spacer" type="description"> </param> + <param _gui-text="Work around renderer bugs" + _gui-description="Works around some common renderer bugs (mainly libRSVG) at the cost of a slightly larger SVG file." + name="renderer-workaround" type="boolean">true</param> + </page> + <page name="Output" _gui-text="SVG Output"> + <_param name="SVG_doc" type="description" appearance="header">Document options</_param> + <param _gui-text="Remove the XML declaration" + _gui-description="Removes the XML declaration (which is optional but should be provided, especially if special characters are used in the document) from the file header." + name="strip-xml-prolog" type="boolean">false</param> + <param _gui-text="Remove metadata" + _gui-description="Remove metadata tags along with all the contained information, which may include license and author information, alternate versions for non-SVG-enabled browsers, etc." + name="remove-metadata" type="boolean">false</param> + <param _gui-text="Remove comments" + _gui-description="Remove all XML comments from output." + name="enable-comment-stripping" type="boolean">false</param> + <param _gui-text="Embed raster images" + _gui-description="Resolve external references to raster images and embed them as Base64-encoded data URLs." + name="embed-rasters" type="boolean">true</param> + <param _gui-text="Enable viewboxing" + _gui-description="Set page size to 100%/100% (full width and height of the display area) and introduce a viewBox specifying the drawings dimensions." + name="enable-viewboxing" type="boolean">false</param> + <param name="spacer" type="description"> </param> + <_param name="pretty_print" type="description" appearance="header">Pretty-printing</_param> + <param _gui-text="Format output with line-breaks and indentation" + _gui-description="Produce nicely formatted output including line-breaks. If you do not intend to hand-edit the SVG file you can disable this option to bring down the file size even more at the cost of clarity." + name="line-breaks" type="boolean">true</param> + <param _gui-text="Indentation characters:" + _gui-description="The type of indentation used for each level of nesting in the output. Specify "None" to disable indentation. This option has no effect if "Format output with line-breaks and indentation" is disabled." + name="indent" type="enum"> <_item value="space">Space</_item> <_item value="tab">Tab</_item> <_item msgctxt="Indent" value="none">None</_item> </param> + <param _gui-text="Depth of indentation:" + _gui-description="The depth of the chosen type of indentation. E.g. if you choose "2" every nesting level in the output will be indented by two additional spaces/tabs." + name="nindent" type="int">1</param> + <param _gui-text="Strip the "xml:space" attribute from the root SVG element" + _gui-description="This is useful if the input file specifies "xml:space='preserve'" in the root SVG element which instructs the SVG editor not to change whitespace in the document at all (and therefore overrides the options above)." + name="strip-xml-space" type="boolean">false</param> </page> - <page name="Ids" _gui-text="Ids"> - <param name="enable-id-stripping" type="boolean" _gui-text="Remove unused ID names for elements">false</param> - <param name="shorten-ids" type="boolean" _gui-text="Shorten IDs">false</param> - <param name="protect-ids-noninkscape" type="boolean" _gui-text="Preserve manually created ID names not ending with digits">false</param> - <param name="protect-ids-list" type="string" _gui-text="Preserve these ID names, comma-separated:"></param> - <param name="protect-ids-prefix" type="string" _gui-text="Preserve ID names starting with:"></param> - </page> - <page name="OptionHelp" _gui-text="Help (Options)"> - <_param name="OptionsInstructions" type="description" xml:space="preserve">This extension optimizes the SVG file according to the following options: - * Shorten color names: convert all colors to #RRGGBB or #RGB format. - * Convert CSS attributes to XML attributes: convert styles from style tags and inline style="" declarations into XML attributes. - * Group collapsing: removes useless g elements, promoting their contents up one level. Requires "Remove unused ID names for elements" to be set. - * Create groups for similar attributes: create g elements for runs of elements having at least one attribute in common (e.g. fill color, stroke opacity, ...). - * Embed rasters: embed raster images as base64-encoded data URLs. - * Keep editor data: don't remove Inkscape, Sodipodi or Adobe Illustrator elements and attributes. - * Remove metadata: remove metadata tags along with all the information in them, which may include license metadata, alternate versions for non-SVG-enabled browsers, etc. - * Remove comments: remove comment tags. - * Work around renderer bugs: emits slightly larger SVG data, but works around a bug in librsvg's renderer, which is used in Eye of GNOME and other various applications. - * Enable viewboxing: size image to 100%/100% and introduce a viewBox. - * Number of significant digits for coords: all coordinates are output with that number of significant digits. For example, if 3 is specified, the coordinate 3.5153 is output as 3.51 and the coordinate 471.55 is output as 472. - * XML indentation (pretty-printing): either None for no indentation, Space to use one space per nesting level, or Tab to use one tab per nesting level.</_param> - </page> - <page name="IdHelp" _gui-text="Help (Ids)"> - <_param name="IDInstructions" type="description" xml:space="preserve">Ids specific options: - * Remove unused ID names for elements: remove all unreferenced ID attributes. - * Shorten IDs: reduce the length of all ID attributes, assigning the shortest to the most-referenced elements. For instance, #linearGradient5621, referenced 100 times, can become #a. - * Preserve manually created ID names not ending with digits: usually, optimised SVG output removes these, but if they're needed for referencing (e.g. #middledot), you may use this option. - * Preserve these ID names, comma-separated: you can use this in conjunction with the other preserve options if you wish to preserve some more specific ID names. - * Preserve ID names starting with: usually, optimised SVG output removes all unused ID names, but if all of your preserved ID names start with the same prefix (e.g. #flag-mx, #flag-pt), you may use this option.</_param> + <page name="IDs" _gui-text="IDs"> + <param _gui-text="Remove unused IDs" + _gui-description="Remove all unreferenced IDs from elements. Those are not needed for rendering." + name="enable-id-stripping" type="boolean">true</param> + <param name="spacer" type="description"> </param> + <param _gui-text="Shorten IDs" + _gui-description="Minimize the length of IDs using only lowercase letters, assigning the shortest values to the most-referenced elements. For instance, "linearGradient5621" will become "a" if it is the most used element." + name="shorten-ids" type="boolean">false</param> + <param _gui-text="Prefix shortened IDs with:" + _gui-description="Prepend shortened IDs with the specified prefix." + name="shorten-ids-prefix" type="string"></param> + <param name="spacer" type="description"> </param> + <param _gui-text="Preserve manually created IDs not ending with digits" + _gui-description="Descriptive IDs which were manually created to reference or label specific elements or groups (e.g. #arrowStart, #arrowEnd or #textLabels) will be preserved while numbered IDs (as they are generated by most SVG editors including Inkscape) will be removed/shortened." + name="protect-ids-noninkscape" type="boolean">true</param> + <param _gui-text="Preserve the following IDs:" + _gui-description="A comma-separated list of IDs that are to be preserved." + name="protect-ids-list" type="string"></param> + <param _gui-text="Preserve IDs starting with:" + _gui-description="Preserve all IDs that start with the specified prefix (e.g. specify "flag" to preserve "flag-mx", "flag-pt", etc.)." + name="protect-ids-prefix" type="string"></param> </page> - </param> + </param> <output> <extension>.svg</extension> <mimetype>image/svg+xml</mimetype> @@ -63,6 +100,6 @@ <_filetypetooltip>Scalable Vector Graphics</_filetypetooltip> </output> <script> - <command reldir="extensions" interpreter="python">scour/scour.inkscape.py</command> + <command reldir="extensions" interpreter="python">scour.inkscape.py</command> </script> </inkscape-extension> diff --git a/share/extensions/scour/Makefile.am b/share/extensions/scour/Makefile.am deleted file mode 100644 index 8a6f42544..000000000 --- a/share/extensions/scour/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ - -scourdir = $(datadir)/inkscape/extensions/scour - -scour_DATA = \ - scour.py \ - scour.inkscape.py \ - svg_regex.py \ - svg_transform.py \ - yocto_css.py - -EXTRA_DIST = \ - $(scour_DATA) - diff --git a/share/extensions/scour/scour.inkscape.py b/share/extensions/scour/scour.inkscape.py deleted file mode 100644 index f161a09c2..000000000 --- a/share/extensions/scour/scour.inkscape.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import sys, inkex -from scour import scourString - -class ScourInkscape (inkex.Effect): - - def __init__(self): - inkex.Effect.__init__(self) - self.OptionParser.add_option("--tab", - action="store", type="string", - dest="tab") - self.OptionParser.add_option("--simplify-colors", type="inkbool", - action="store", dest="simple_colors", default=True, - help="won't convert all colors to #RRGGBB format") - self.OptionParser.add_option("--style-to-xml", type="inkbool", - action="store", dest="style_to_xml", default=True, - help="won't convert styles into XML attributes") - self.OptionParser.add_option("--group-collapsing", type="inkbool", - action="store", dest="group_collapse", default=True, - help="won't collapse <g> elements") - self.OptionParser.add_option("--create-groups", type="inkbool", - action="store", dest="group_create", default=False, - help="create <g> elements for runs of elements with identical attributes") - self.OptionParser.add_option("--enable-id-stripping", type="inkbool", - action="store", dest="strip_ids", default=False, - help="remove all un-referenced ID attributes") - self.OptionParser.add_option("--shorten-ids", type="inkbool", - action="store", dest="shorten_ids", default=False, - help="shorten all ID attributes to the least number of letters possible") - self.OptionParser.add_option("--embed-rasters", type="inkbool", - action="store", dest="embed_rasters", default=True, - help="won't embed rasters as base64-encoded data") - self.OptionParser.add_option("--keep-editor-data", type="inkbool", - action="store", dest="keep_editor_data", default=False, - help="won't remove Inkscape, Sodipodi or Adobe Illustrator elements and attributes") - self.OptionParser.add_option("--remove-metadata", type="inkbool", - action="store", dest="remove_metadata", default=False, - help="remove <metadata> elements (which may contain license metadata etc.)") - self.OptionParser.add_option("--strip-xml-prolog", type="inkbool", - action="store", dest="strip_xml_prolog", default=False, - help="won't output the <?xml ?> prolog") - self.OptionParser.add_option("-p", "--set-precision", - action="store", type=int, dest="digits", default=5, - help="set number of significant digits (default: %default)") - self.OptionParser.add_option("--indent", - action="store", type="string", dest="indent_type", default="space", - help="indentation of the output: none, space, tab (default: %default)") - self.OptionParser.add_option("--protect-ids-noninkscape", type="inkbool", - action="store", dest="protect_ids_noninkscape", default=False, - help="don't change IDs not ending with a digit") - self.OptionParser.add_option("--protect-ids-list", - action="store", type="string", dest="protect_ids_list", default=None, - help="don't change IDs given in a comma-separated list") - self.OptionParser.add_option("--protect-ids-prefix", - action="store", type="string", dest="protect_ids_prefix", default=None, - help="don't change IDs starting with the given prefix") - self.OptionParser.add_option("--enable-viewboxing", type="inkbool", - action="store", dest="enable_viewboxing", default=False, - help="changes document width/height to 100%/100% and creates viewbox coordinates") - self.OptionParser.add_option("--enable-comment-stripping", type="inkbool", - action="store", dest="strip_comments", default=False, - help="remove all <!-- --> comments") - self.OptionParser.add_option("--renderer-workaround", type="inkbool", - action="store", dest="renderer_workaround", default=False, - help="work around various renderer bugs (currently only librsvg)") - - def effect(self): - input = file(self.args[0], "r") - self.options.infilename=self.args[0] - sys.stdout.write(scourString(input.read(), self.options).encode("UTF-8")) - input.close() - sys.stdout.close() - - -if __name__ == '__main__': - e = ScourInkscape() - e.affect(output=False) diff --git a/share/extensions/scour/scour.py b/share/extensions/scour/scour.py deleted file mode 100644 index 236529daa..000000000 --- a/share/extensions/scour/scour.py +++ /dev/null @@ -1,3235 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Scour -# -# Copyright 2010 Jeff Schiller -# Copyright 2010 Louis Simard -# -# This file is part of Scour, http://www.codedread.com/scour/ -# -# This library is free software; you can redistribute it and/or modify -# it either under the terms of the Apache License, Version 2.0, or, at -# your option, under the terms and conditions of the GNU General -# Public License, Version 2 or newer as published by the Free Software -# Foundation. You may obtain a copy of these Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Notes: - -# rubys' path-crunching ideas here: http://intertwingly.net/code/svgtidy/spec.rb -# (and implemented here: http://intertwingly.net/code/svgtidy/svgtidy.rb ) - -# Yet more ideas here: http://wiki.inkscape.org/wiki/index.php/Save_Cleaned_SVG -# -# * Process Transformations -# * Collapse all group based transformations - -# Even more ideas here: http://esw.w3.org/topic/SvgTidy -# * analysis of path elements to see if rect can be used instead? (must also need to look -# at rounded corners) - -# Next Up: -# - why are marker-start, -end not removed from the style attribute? -# - why are only overflow style properties considered and not attributes? -# - only remove unreferenced elements if they are not children of a referenced element -# - add an option to remove ids if they match the Inkscape-style of IDs -# - investigate point-reducing algorithms -# - parse transform attribute -# - if a <g> has only one element in it, collapse the <g> (ensure transform, etc are carried down) - -# necessary to get true division -from __future__ import division - -import os -import sys -import xml.dom.minidom -import re -import math -from svg_regex import svg_parser -from svg_transform import svg_transform_parser -import optparse -from yocto_css import parseCssString - -# Python 2.3- did not have Decimal -try: - from decimal import * -except ImportError: - print >>sys.stderr, "Scour requires Python 2.4." - -# Import Psyco if available -try: - import psyco - psyco.full() -except ImportError: - pass - -APP = 'scour' -VER = '0.26+r220' -COPYRIGHT = 'Copyright Jeff Schiller, Louis Simard, 2012' - -NS = { 'SVG': 'http://www.w3.org/2000/svg', - 'XLINK': 'http://www.w3.org/1999/xlink', - 'SODIPODI': 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd', - 'INKSCAPE': 'http://www.inkscape.org/namespaces/inkscape', - 'ADOBE_ILLUSTRATOR': 'http://ns.adobe.com/AdobeIllustrator/10.0/', - 'ADOBE_GRAPHS': 'http://ns.adobe.com/Graphs/1.0/', - 'ADOBE_SVG_VIEWER': 'http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/', - 'ADOBE_VARIABLES': 'http://ns.adobe.com/Variables/1.0/', - 'ADOBE_SFW': 'http://ns.adobe.com/SaveForWeb/1.0/', - 'ADOBE_EXTENSIBILITY': 'http://ns.adobe.com/Extensibility/1.0/', - 'ADOBE_FLOWS': 'http://ns.adobe.com/Flows/1.0/', - 'ADOBE_IMAGE_REPLACEMENT': 'http://ns.adobe.com/ImageReplacement/1.0/', - 'ADOBE_CUSTOM': 'http://ns.adobe.com/GenericCustomNamespace/1.0/', - 'ADOBE_XPATH': 'http://ns.adobe.com/XPath/1.0/' - } - -unwanted_ns = [ NS['SODIPODI'], NS['INKSCAPE'], NS['ADOBE_ILLUSTRATOR'], - NS['ADOBE_GRAPHS'], NS['ADOBE_SVG_VIEWER'], NS['ADOBE_VARIABLES'], - NS['ADOBE_SFW'], NS['ADOBE_EXTENSIBILITY'], NS['ADOBE_FLOWS'], - NS['ADOBE_IMAGE_REPLACEMENT'], NS['ADOBE_CUSTOM'], NS['ADOBE_XPATH'] ] - -svgAttributes = [ - 'clip-rule', - 'display', - 'fill', - 'fill-opacity', - 'fill-rule', - 'filter', - 'font-family', - 'font-size', - 'font-stretch', - 'font-style', - 'font-variant', - 'font-weight', - 'line-height', - 'marker', - 'marker-end', - 'marker-mid', - 'marker-start', - 'opacity', - 'overflow', - 'stop-color', - 'stop-opacity', - 'stroke', - 'stroke-dasharray', - 'stroke-dashoffset', - 'stroke-linecap', - 'stroke-linejoin', - 'stroke-miterlimit', - 'stroke-opacity', - 'stroke-width', - 'visibility' - ] - -colors = { - 'aliceblue': 'rgb(240, 248, 255)', - 'antiquewhite': 'rgb(250, 235, 215)', - 'aqua': 'rgb( 0, 255, 255)', - 'aquamarine': 'rgb(127, 255, 212)', - 'azure': 'rgb(240, 255, 255)', - 'beige': 'rgb(245, 245, 220)', - 'bisque': 'rgb(255, 228, 196)', - 'black': 'rgb( 0, 0, 0)', - 'blanchedalmond': 'rgb(255, 235, 205)', - 'blue': 'rgb( 0, 0, 255)', - 'blueviolet': 'rgb(138, 43, 226)', - 'brown': 'rgb(165, 42, 42)', - 'burlywood': 'rgb(222, 184, 135)', - 'cadetblue': 'rgb( 95, 158, 160)', - 'chartreuse': 'rgb(127, 255, 0)', - 'chocolate': 'rgb(210, 105, 30)', - 'coral': 'rgb(255, 127, 80)', - 'cornflowerblue': 'rgb(100, 149, 237)', - 'cornsilk': 'rgb(255, 248, 220)', - 'crimson': 'rgb(220, 20, 60)', - 'cyan': 'rgb( 0, 255, 255)', - 'darkblue': 'rgb( 0, 0, 139)', - 'darkcyan': 'rgb( 0, 139, 139)', - 'darkgoldenrod': 'rgb(184, 134, 11)', - 'darkgray': 'rgb(169, 169, 169)', - 'darkgreen': 'rgb( 0, 100, 0)', - 'darkgrey': 'rgb(169, 169, 169)', - 'darkkhaki': 'rgb(189, 183, 107)', - 'darkmagenta': 'rgb(139, 0, 139)', - 'darkolivegreen': 'rgb( 85, 107, 47)', - 'darkorange': 'rgb(255, 140, 0)', - 'darkorchid': 'rgb(153, 50, 204)', - 'darkred': 'rgb(139, 0, 0)', - 'darksalmon': 'rgb(233, 150, 122)', - 'darkseagreen': 'rgb(143, 188, 143)', - 'darkslateblue': 'rgb( 72, 61, 139)', - 'darkslategray': 'rgb( 47, 79, 79)', - 'darkslategrey': 'rgb( 47, 79, 79)', - 'darkturquoise': 'rgb( 0, 206, 209)', - 'darkviolet': 'rgb(148, 0, 211)', - 'deeppink': 'rgb(255, 20, 147)', - 'deepskyblue': 'rgb( 0, 191, 255)', - 'dimgray': 'rgb(105, 105, 105)', - 'dimgrey': 'rgb(105, 105, 105)', - 'dodgerblue': 'rgb( 30, 144, 255)', - 'firebrick': 'rgb(178, 34, 34)', - 'floralwhite': 'rgb(255, 250, 240)', - 'forestgreen': 'rgb( 34, 139, 34)', - 'fuchsia': 'rgb(255, 0, 255)', - 'gainsboro': 'rgb(220, 220, 220)', - 'ghostwhite': 'rgb(248, 248, 255)', - 'gold': 'rgb(255, 215, 0)', - 'goldenrod': 'rgb(218, 165, 32)', - 'gray': 'rgb(128, 128, 128)', - 'grey': 'rgb(128, 128, 128)', - 'green': 'rgb( 0, 128, 0)', - 'greenyellow': 'rgb(173, 255, 47)', - 'honeydew': 'rgb(240, 255, 240)', - 'hotpink': 'rgb(255, 105, 180)', - 'indianred': 'rgb(205, 92, 92)', - 'indigo': 'rgb( 75, 0, 130)', - 'ivory': 'rgb(255, 255, 240)', - 'khaki': 'rgb(240, 230, 140)', - 'lavender': 'rgb(230, 230, 250)', - 'lavenderblush': 'rgb(255, 240, 245)', - 'lawngreen': 'rgb(124, 252, 0)', - 'lemonchiffon': 'rgb(255, 250, 205)', - 'lightblue': 'rgb(173, 216, 230)', - 'lightcoral': 'rgb(240, 128, 128)', - 'lightcyan': 'rgb(224, 255, 255)', - 'lightgoldenrodyellow': 'rgb(250, 250, 210)', - 'lightgray': 'rgb(211, 211, 211)', - 'lightgreen': 'rgb(144, 238, 144)', - 'lightgrey': 'rgb(211, 211, 211)', - 'lightpink': 'rgb(255, 182, 193)', - 'lightsalmon': 'rgb(255, 160, 122)', - 'lightseagreen': 'rgb( 32, 178, 170)', - 'lightskyblue': 'rgb(135, 206, 250)', - 'lightslategray': 'rgb(119, 136, 153)', - 'lightslategrey': 'rgb(119, 136, 153)', - 'lightsteelblue': 'rgb(176, 196, 222)', - 'lightyellow': 'rgb(255, 255, 224)', - 'lime': 'rgb( 0, 255, 0)', - 'limegreen': 'rgb( 50, 205, 50)', - 'linen': 'rgb(250, 240, 230)', - 'magenta': 'rgb(255, 0, 255)', - 'maroon': 'rgb(128, 0, 0)', - 'mediumaquamarine': 'rgb(102, 205, 170)', - 'mediumblue': 'rgb( 0, 0, 205)', - 'mediumorchid': 'rgb(186, 85, 211)', - 'mediumpurple': 'rgb(147, 112, 219)', - 'mediumseagreen': 'rgb( 60, 179, 113)', - 'mediumslateblue': 'rgb(123, 104, 238)', - 'mediumspringgreen': 'rgb( 0, 250, 154)', - 'mediumturquoise': 'rgb( 72, 209, 204)', - 'mediumvioletred': 'rgb(199, 21, 133)', - 'midnightblue': 'rgb( 25, 25, 112)', - 'mintcream': 'rgb(245, 255, 250)', - 'mistyrose': 'rgb(255, 228, 225)', - 'moccasin': 'rgb(255, 228, 181)', - 'navajowhite': 'rgb(255, 222, 173)', - 'navy': 'rgb( 0, 0, 128)', - 'oldlace': 'rgb(253, 245, 230)', - 'olive': 'rgb(128, 128, 0)', - 'olivedrab': 'rgb(107, 142, 35)', - 'orange': 'rgb(255, 165, 0)', - 'orangered': 'rgb(255, 69, 0)', - 'orchid': 'rgb(218, 112, 214)', - 'palegoldenrod': 'rgb(238, 232, 170)', - 'palegreen': 'rgb(152, 251, 152)', - 'paleturquoise': 'rgb(175, 238, 238)', - 'palevioletred': 'rgb(219, 112, 147)', - 'papayawhip': 'rgb(255, 239, 213)', - 'peachpuff': 'rgb(255, 218, 185)', - 'peru': 'rgb(205, 133, 63)', - 'pink': 'rgb(255, 192, 203)', - '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)', - 'saddlebrown': 'rgb(139, 69, 19)', - 'salmon': 'rgb(250, 128, 114)', - 'sandybrown': 'rgb(244, 164, 96)', - 'seagreen': 'rgb( 46, 139, 87)', - 'seashell': 'rgb(255, 245, 238)', - 'sienna': 'rgb(160, 82, 45)', - 'silver': 'rgb(192, 192, 192)', - 'skyblue': 'rgb(135, 206, 235)', - 'slateblue': 'rgb(106, 90, 205)', - 'slategray': 'rgb(112, 128, 144)', - 'slategrey': 'rgb(112, 128, 144)', - 'snow': 'rgb(255, 250, 250)', - 'springgreen': 'rgb( 0, 255, 127)', - 'steelblue': 'rgb( 70, 130, 180)', - 'tan': 'rgb(210, 180, 140)', - 'teal': 'rgb( 0, 128, 128)', - 'thistle': 'rgb(216, 191, 216)', - 'tomato': 'rgb(255, 99, 71)', - 'turquoise': 'rgb( 64, 224, 208)', - 'violet': 'rgb(238, 130, 238)', - 'wheat': 'rgb(245, 222, 179)', - 'white': 'rgb(255, 255, 255)', - 'whitesmoke': 'rgb(245, 245, 245)', - 'yellow': 'rgb(255, 255, 0)', - 'yellowgreen': 'rgb(154, 205, 50)', - } - -default_attributes = { # excluded all attributes with 'auto' as default - # SVG 1.1 presentation attributes - 'baseline-shift': 'baseline', - 'clip-path': 'none', - 'clip-rule': 'nonzero', - 'color': '#000', - 'color-interpolation-filters': 'linearRGB', - 'color-interpolation': 'sRGB', - 'direction': 'ltr', - 'display': 'inline', - 'enable-background': 'accumulate', - 'fill': '#000', - 'fill-opacity': '1', - 'fill-rule': 'nonzero', - 'filter': 'none', - 'flood-color': '#000', - 'flood-opacity': '1', - 'font-size-adjust': 'none', - 'font-size': 'medium', - 'font-stretch': 'normal', - 'font-style': 'normal', - 'font-variant': 'normal', - 'font-weight': 'normal', - 'glyph-orientation-horizontal': '0deg', - 'letter-spacing': 'normal', - 'lighting-color': '#fff', - 'marker': 'none', - 'marker-start': 'none', - 'marker-mid': 'none', - 'marker-end': 'none', - 'mask': 'none', - 'opacity': '1', - 'pointer-events': 'visiblePainted', - 'stop-color': '#000', - 'stop-opacity': '1', - 'stroke': 'none', - 'stroke-dasharray': 'none', - 'stroke-dashoffset': '0', - 'stroke-linecap': 'butt', - 'stroke-linejoin': 'miter', - 'stroke-miterlimit': '4', - 'stroke-opacity': '1', - 'stroke-width': '1', - 'text-anchor': 'start', - 'text-decoration': 'none', - 'unicode-bidi': 'normal', - 'visibility': 'visible', - 'word-spacing': 'normal', - 'writing-mode': 'lr-tb', - # SVG 1.2 tiny properties - 'audio-level': '1', - 'solid-color': '#000', - 'solid-opacity': '1', - 'text-align': 'start', - 'vector-effect': 'none', - 'viewport-fill': 'none', - 'viewport-fill-opacity': '1', - } - -def isSameSign(a,b): return (a <= 0 and b <= 0) or (a >= 0 and b >= 0) - -scinumber = re.compile(r"[-+]?(\d*\.?)?\d+[eE][-+]?\d+") -number = re.compile(r"[-+]?(\d*\.?)?\d+") -sciExponent = re.compile(r"[eE]([-+]?\d+)") -unit = re.compile("(em|ex|px|pt|pc|cm|mm|in|%){1,1}$") - -class Unit(object): - # Integer constants for units. - INVALID = -1 - NONE = 0 - PCT = 1 - PX = 2 - PT = 3 - PC = 4 - EM = 5 - EX = 6 - CM = 7 - MM = 8 - IN = 9 - - # String to Unit. Basically, converts unit strings to their integer constants. - s2u = { - '': NONE, - '%': PCT, - 'px': PX, - 'pt': PT, - 'pc': PC, - 'em': EM, - 'ex': EX, - 'cm': CM, - 'mm': MM, - 'in': IN, - } - - # Unit to String. Basically, converts unit integer constants to their corresponding strings. - u2s = { - NONE: '', - PCT: '%', - PX: 'px', - PT: 'pt', - PC: 'pc', - EM: 'em', - EX: 'ex', - CM: 'cm', - MM: 'mm', - IN: 'in', - } - -# @staticmethod - def get(unitstr): - if unitstr is None: return Unit.NONE - try: - return Unit.s2u[unitstr] - except KeyError: - return Unit.INVALID - -# @staticmethod - def str(unitint): - try: - return Unit.u2s[unitint] - except KeyError: - return 'INVALID' - - get = staticmethod(get) - str = staticmethod(str) - -class SVGLength(object): - def __init__(self, str): - try: # simple unitless and no scientific notation - self.value = float(str) - if int(self.value) == self.value: - self.value = int(self.value) - self.units = Unit.NONE - except ValueError: - # we know that the length string has an exponent, a unit, both or is invalid - - # parse out number, exponent and unit - self.value = 0 - unitBegin = 0 - scinum = scinumber.match(str) - if scinum != None: - # this will always match, no need to check it - numMatch = number.match(str) - expMatch = sciExponent.search(str, numMatch.start(0)) - self.value = (float(numMatch.group(0)) * - 10 ** float(expMatch.group(1))) - unitBegin = expMatch.end(1) - else: - # unit or invalid - numMatch = number.match(str) - if numMatch != None: - self.value = float(numMatch.group(0)) - unitBegin = numMatch.end(0) - - if int(self.value) == self.value: - self.value = int(self.value) - - if unitBegin != 0 : - unitMatch = unit.search(str, unitBegin) - if unitMatch != None : - self.units = Unit.get(unitMatch.group(0)) - - # invalid - else: - # TODO: this needs to set the default for the given attribute (how?) - self.value = 0 - self.units = Unit.INVALID - -def findElementsWithId(node, elems=None): - """ - Returns all elements with id attributes - """ - if elems is None: - elems = {} - id = node.getAttribute('id') - if id != '' : - elems[id] = node - if node.hasChildNodes() : - for child in node.childNodes: - # from http://www.w3.org/TR/DOM-Level-2-Core/idl-definitions.html - # we are only really interested in nodes of type Element (1) - if child.nodeType == 1 : - findElementsWithId(child, elems) - return elems - -referencingProps = ['fill', 'stroke', 'filter', 'clip-path', 'mask', 'marker-start', - 'marker-end', 'marker-mid'] - -def findReferencedElements(node, ids=None): - """ - Returns the number of times an ID is referenced as well as all elements - that reference it. node is the node at which to start the search. The - return value is a map which has the id as key and each value is an array - where the first value is a count and the second value is a list of nodes - that referenced it. - - Currently looks at fill, stroke, clip-path, mask, marker, and - xlink:href attributes. - """ - global referencingProps - if ids is None: - ids = {} - # TODO: input argument ids is clunky here (see below how it is called) - # GZ: alternative to passing dict, use **kwargs - - # if this node is a style element, parse its text into CSS - if node.nodeName == 'style' and node.namespaceURI == NS['SVG']: - # one stretch of text, please! (we could use node.normalize(), but - # this actually modifies the node, and we don't want to keep - # whitespace around if there's any) - stylesheet = "".join([child.nodeValue for child in node.childNodes]) - if stylesheet != '': - cssRules = parseCssString(stylesheet) - for rule in cssRules: - for propname in rule['properties']: - propval = rule['properties'][propname] - findReferencingProperty(node, propname, propval, ids) - return ids - - # else if xlink:href is set, then grab the id - href = node.getAttributeNS(NS['XLINK'],'href') - if href != '' and len(href) > 1 and href[0] == '#': - # we remove the hash mark from the beginning of the id - id = href[1:] - if id in ids: - ids[id][0] += 1 - ids[id][1].append(node) - else: - ids[id] = [1,[node]] - - # now get all style properties and the fill, stroke, filter attributes - styles = node.getAttribute('style').split(';') - for attr in referencingProps: - styles.append(':'.join([attr, node.getAttribute(attr)])) - - for style in styles: - propval = style.split(':') - if len(propval) == 2 : - prop = propval[0].strip() - val = propval[1].strip() - findReferencingProperty(node, prop, val, ids) - - if node.hasChildNodes() : - for child in node.childNodes: - if child.nodeType == 1 : - findReferencedElements(child, ids) - return ids - -def findReferencingProperty(node, prop, val, ids): - global referencingProps - if prop in referencingProps and val != '' : - if len(val) >= 7 and val[0:5] == 'url(#' : - id = val[5:val.find(')')] - if ids.has_key(id) : - ids[id][0] += 1 - ids[id][1].append(node) - else: - ids[id] = [1,[node]] - # if the url has a quote in it, we need to compensate - elif len(val) >= 8 : - id = None - # double-quote - if val[0:6] == 'url("#' : - id = val[6:val.find('")')] - # single-quote - elif val[0:6] == "url('#" : - id = val[6:val.find("')")] - if id != None: - if ids.has_key(id) : - ids[id][0] += 1 - ids[id][1].append(node) - else: - ids[id] = [1,[node]] - -numIDsRemoved = 0 -numElemsRemoved = 0 -numAttrsRemoved = 0 -numRastersEmbedded = 0 -numPathSegmentsReduced = 0 -numCurvesStraightened = 0 -numBytesSavedInPathData = 0 -numBytesSavedInColors = 0 -numBytesSavedInIDs = 0 -numBytesSavedInLengths = 0 -numBytesSavedInTransforms = 0 -numPointsRemovedFromPolygon = 0 -numCommentBytes = 0 - -def flattenDefs(doc): - """ - Puts all defined elements into a newly created defs in the document. This function - handles recursive defs elements. - """ - defs = doc.documentElement.getElementsByTagName('defs') - - if defs.length > 1: - topDef = doc.createElementNS(NS['SVG'], 'defs') - - for defElem in defs: - # Remove all children of this defs and put it into the topDef. - while defElem.hasChildNodes(): - topDef.appendChild(defElem.firstChild) - defElem.parentNode.removeChild(defElem) - - if topDef.hasChildNodes(): - doc.documentElement.insertBefore(topDef, doc.documentElement.firstChild) - -def removeUnusedDefs(doc, defElem, elemsToRemove=None): - if elemsToRemove is None: - elemsToRemove = [] - - identifiedElements = findElementsWithId(doc.documentElement) - referencedIDs = findReferencedElements(doc.documentElement) - - keepTags = ['font', 'style', 'metadata', 'script', 'title', 'desc'] - for elem in defElem.childNodes: - # only look at it if an element and not referenced anywhere else - if elem.nodeType == 1 and (elem.getAttribute('id') == '' or \ - (not elem.getAttribute('id') in referencedIDs)): - - # we only inspect the children of a group in a defs if the group - # is not referenced anywhere else - if elem.nodeName == 'g' and elem.namespaceURI == NS['SVG']: - elemsToRemove = removeUnusedDefs(doc, elem, elemsToRemove) - # we only remove if it is not one of our tags we always keep (see above) - elif not elem.nodeName in keepTags: - elemsToRemove.append(elem) - return elemsToRemove - -def removeUnreferencedElements(doc): - """ - Removes all unreferenced elements except for <svg>, <font>, <metadata>, <title>, and <desc>. - Also vacuums the defs of any non-referenced renderable elements. - - Returns the number of unreferenced elements removed from the document. - """ - global numElemsRemoved - num = 0 - - # Remove certain unreferenced elements outside of defs - removeTags = ['linearGradient', 'radialGradient', 'pattern'] - identifiedElements = findElementsWithId(doc.documentElement) - referencedIDs = findReferencedElements(doc.documentElement) - - for id in identifiedElements: - if not id in referencedIDs: - goner = identifiedElements[id] - if goner != None and goner.parentNode != None and goner.nodeName in removeTags: - goner.parentNode.removeChild(goner) - num += 1 - numElemsRemoved += 1 - - # Remove most unreferenced elements inside defs - defs = doc.documentElement.getElementsByTagName('defs') - for aDef in defs: - elemsToRemove = removeUnusedDefs(doc, aDef) - for elem in elemsToRemove: - elem.parentNode.removeChild(elem) - numElemsRemoved += 1 - num += 1 - return num - -def shortenIDs(doc, unprotectedElements=None): - """ - Shortens ID names used in the document. ID names referenced the most often are assigned the - shortest ID names. - If the list unprotectedElements is provided, only IDs from this list will be shortened. - - Returns the number of bytes saved by shortening ID names in the document. - """ - num = 0 - - identifiedElements = findElementsWithId(doc.documentElement) - if unprotectedElements is None: - unprotectedElements = identifiedElements - referencedIDs = findReferencedElements(doc.documentElement) - - # Make idList (list of idnames) sorted by reference count - # descending, so the highest reference count is first. - # First check that there's actually a defining element for the current ID name. - # (Cyn: I've seen documents with #id references but no element with that ID!) - idList = [(referencedIDs[rid][0], rid) for rid in referencedIDs - if rid in unprotectedElements] - idList.sort(reverse=True) - idList = [rid for count, rid in idList] - - curIdNum = 1 - - for rid in idList: - curId = intToID(curIdNum) - # First make sure that *this* element isn't already using - # the ID name we want to give it. - if curId != rid: - # Then, skip ahead if the new ID is already in identifiedElement. - while curId in identifiedElements: - curIdNum += 1 - curId = intToID(curIdNum) - # Then go rename it. - num += renameID(doc, rid, curId, identifiedElements, referencedIDs) - curIdNum += 1 - - return num - -def intToID(idnum): - """ - Returns the ID name for the given ID number, spreadsheet-style, i.e. from a to z, - then from aa to az, ba to bz, etc., until zz. - """ - rid = '' - - while idnum > 0: - idnum -= 1 - rid = chr((idnum % 26) + ord('a')) + rid - idnum = int(idnum / 26) - - return rid - -def renameID(doc, idFrom, idTo, identifiedElements, referencedIDs): - """ - Changes the ID name from idFrom to idTo, on the declaring element - as well as all references in the document doc. - - Updates identifiedElements and referencedIDs. - Does not handle the case where idTo is already the ID name - of another element in doc. - - Returns the number of bytes saved by this replacement. - """ - - num = 0 - - definingNode = identifiedElements[idFrom] - definingNode.setAttribute("id", idTo) - del identifiedElements[idFrom] - identifiedElements[idTo] = definingNode - - referringNodes = referencedIDs[idFrom] - - # Look for the idFrom ID name in each of the referencing elements, - # exactly like findReferencedElements would. - # Cyn: Duplicated processing! - - for node in referringNodes[1]: - # if this node is a style element, parse its text into CSS - if node.nodeName == 'style' and node.namespaceURI == NS['SVG']: - # node.firstChild will be either a CDATA or a Text node now - if node.firstChild != None: - # concatenate the value of all children, in case - # there's a CDATASection node surrounded by whitespace - # nodes - # (node.normalize() will NOT work here, it only acts on Text nodes) - oldValue = "".join([child.nodeValue for child in node.childNodes]) - # not going to reparse the whole thing - newValue = oldValue.replace('url(#' + idFrom + ')', 'url(#' + idTo + ')') - newValue = newValue.replace("url(#'" + idFrom + "')", 'url(#' + idTo + ')') - newValue = newValue.replace('url(#"' + idFrom + '")', 'url(#' + idTo + ')') - # and now replace all the children with this new stylesheet. - # again, this is in case the stylesheet was a CDATASection - node.childNodes[:] = [node.ownerDocument.createTextNode(newValue)] - num += len(oldValue) - len(newValue) - - # if xlink:href is set to #idFrom, then change the id - href = node.getAttributeNS(NS['XLINK'],'href') - if href == '#' + idFrom: - node.setAttributeNS(NS['XLINK'],'href', '#' + idTo) - num += len(idFrom) - len(idTo) - - # if the style has url(#idFrom), then change the id - styles = node.getAttribute('style') - if styles != '': - newValue = styles.replace('url(#' + idFrom + ')', 'url(#' + idTo + ')') - newValue = newValue.replace("url('#" + idFrom + "')", 'url(#' + idTo + ')') - newValue = newValue.replace('url("#' + idFrom + '")', 'url(#' + idTo + ')') - node.setAttribute('style', newValue) - num += len(styles) - len(newValue) - - # now try the fill, stroke, filter attributes - for attr in referencingProps: - oldValue = node.getAttribute(attr) - if oldValue != '': - newValue = oldValue.replace('url(#' + idFrom + ')', 'url(#' + idTo + ')') - newValue = newValue.replace("url('#" + idFrom + "')", 'url(#' + idTo + ')') - newValue = newValue.replace('url("#' + idFrom + '")', 'url(#' + idTo + ')') - node.setAttribute(attr, newValue) - num += len(oldValue) - len(newValue) - - del referencedIDs[idFrom] - referencedIDs[idTo] = referringNodes - - return num - -def unprotected_ids(doc, options): - u"""Returns a list of unprotected IDs within the document doc.""" - identifiedElements = findElementsWithId(doc.documentElement) - if not (options.protect_ids_noninkscape or - options.protect_ids_list or - options.protect_ids_prefix): - return identifiedElements - if options.protect_ids_list: - protect_ids_list = options.protect_ids_list.split(",") - if options.protect_ids_prefix: - protect_ids_prefixes = options.protect_ids_prefix.split(",") - for id in identifiedElements.keys(): - protected = False - if options.protect_ids_noninkscape and not id[-1].isdigit(): - protected = True - if options.protect_ids_list and id in protect_ids_list: - protected = True - if options.protect_ids_prefix: - for prefix in protect_ids_prefixes: - if id.startswith(prefix): - protected = True - if protected: - del identifiedElements[id] - return identifiedElements - -def removeUnreferencedIDs(referencedIDs, identifiedElements): - """ - Removes the unreferenced ID attributes. - - Returns the number of ID attributes removed - """ - global numIDsRemoved - keepTags = ['font'] - num = 0; - for id in identifiedElements.keys(): - node = identifiedElements[id] - if referencedIDs.has_key(id) == False and not node.nodeName in keepTags: - node.removeAttribute('id') - numIDsRemoved += 1 - num += 1 - return num - -def removeNamespacedAttributes(node, namespaces): - global numAttrsRemoved - num = 0 - if node.nodeType == 1 : - # remove all namespace'd attributes from this element - attrList = node.attributes - attrsToRemove = [] - for attrNum in xrange(attrList.length): - attr = attrList.item(attrNum) - if attr != None and attr.namespaceURI in namespaces: - attrsToRemove.append(attr.nodeName) - for attrName in attrsToRemove : - num += 1 - numAttrsRemoved += 1 - node.removeAttribute(attrName) - - # now recurse for children - for child in node.childNodes: - num += removeNamespacedAttributes(child, namespaces) - return num - -def removeNamespacedElements(node, namespaces): - global numElemsRemoved - num = 0 - if node.nodeType == 1 : - # remove all namespace'd child nodes from this element - childList = node.childNodes - childrenToRemove = [] - for child in childList: - if child != None and child.namespaceURI in namespaces: - childrenToRemove.append(child) - for child in childrenToRemove : - num += 1 - numElemsRemoved += 1 - node.removeChild(child) - - # now recurse for children - for child in node.childNodes: - num += removeNamespacedElements(child, namespaces) - return num - -def removeMetadataElements(doc): - global numElemsRemoved - num = 0 - # clone the list, as the tag list is live from the DOM - elementsToRemove = [element for element in doc.documentElement.getElementsByTagName('metadata')] - - for element in elementsToRemove: - element.parentNode.removeChild(element) - num += 1 - numElemsRemoved += 1 - - return num - -def removeNestedGroups(node): - """ - This walks further and further down the tree, removing groups - which do not have any attributes or a title/desc child and - promoting their children up one level - """ - global numElemsRemoved - num = 0 - - groupsToRemove = [] - # Only consider <g> elements for promotion if this element isn't a <switch>. - # (partial fix for bug 594930, required by the SVG spec however) - if not (node.nodeType == 1 and node.nodeName == 'switch'): - for child in node.childNodes: - if child.nodeName == 'g' and child.namespaceURI == NS['SVG'] and len(child.attributes) == 0: - # only collapse group if it does not have a title or desc as a direct descendant, - for grandchild in child.childNodes: - if grandchild.nodeType == 1 and grandchild.namespaceURI == NS['SVG'] and \ - grandchild.nodeName in ['title','desc']: - break - else: - groupsToRemove.append(child) - - for g in groupsToRemove: - while g.childNodes.length > 0: - g.parentNode.insertBefore(g.firstChild, g) - g.parentNode.removeChild(g) - numElemsRemoved += 1 - num += 1 - - # now recurse for children - for child in node.childNodes: - if child.nodeType == 1: - num += removeNestedGroups(child) - return num - -def moveCommonAttributesToParentGroup(elem, referencedElements): - """ - This recursively calls this function on all children of the passed in element - and then iterates over all child elements and removes common inheritable attributes - from the children and places them in the parent group. But only if the parent contains - nothing but element children and whitespace. The attributes are only removed from the - children if the children are not referenced by other elements in the document. - """ - num = 0 - - childElements = [] - # recurse first into the children (depth-first) - for child in elem.childNodes: - if child.nodeType == 1: - # only add and recurse if the child is not referenced elsewhere - if not child.getAttribute('id') in referencedElements: - childElements.append(child) - num += moveCommonAttributesToParentGroup(child, referencedElements) - # else if the parent has non-whitespace text children, do not - # try to move common attributes - elif child.nodeType == 3 and child.nodeValue.strip(): - return num - - # only process the children if there are more than one element - if len(childElements) <= 1: return num - - commonAttrs = {} - # add all inheritable properties of the first child element - # FIXME: Note there is a chance that the first child is a set/animate in which case - # its fill attribute is not what we want to look at, we should look for the first - # non-animate/set element - attrList = childElements[0].attributes - for num in xrange(attrList.length): - attr = attrList.item(num) - # this is most of the inheritable properties from http://www.w3.org/TR/SVG11/propidx.html - # and http://www.w3.org/TR/SVGTiny12/attributeTable.html - if attr.nodeName in ['clip-rule', - 'display-align', - 'fill', 'fill-opacity', 'fill-rule', - 'font', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', - 'font-style', 'font-variant', 'font-weight', - 'letter-spacing', - 'pointer-events', 'shape-rendering', - 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', - 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', - 'text-anchor', 'text-decoration', 'text-rendering', 'visibility', - 'word-spacing', 'writing-mode']: - # we just add all the attributes from the first child - commonAttrs[attr.nodeName] = attr.nodeValue - - # for each subsequent child element - for childNum in xrange(len(childElements)): - # skip first child - if childNum == 0: - continue - - child = childElements[childNum] - # if we are on an animateXXX/set element, ignore it (due to the 'fill' attribute) - if child.localName in ['set', 'animate', 'animateColor', 'animateTransform', 'animateMotion']: - continue - - distinctAttrs = [] - # loop through all current 'common' attributes - for name in commonAttrs.keys(): - # if this child doesn't match that attribute, schedule it for removal - if child.getAttribute(name) != commonAttrs[name]: - distinctAttrs.append(name) - # remove those attributes which are not common - for name in distinctAttrs: - del commonAttrs[name] - - # commonAttrs now has all the inheritable attributes which are common among all child elements - for name in commonAttrs.keys(): - for child in childElements: - child.removeAttribute(name) - elem.setAttribute(name, commonAttrs[name]) - - # update our statistic (we remove N*M attributes and add back in M attributes) - num += (len(childElements)-1) * len(commonAttrs) - return num - -def createGroupsForCommonAttributes(elem): - """ - Creates <g> elements to contain runs of 3 or more - consecutive child elements having at least one common attribute. - - Common attributes are not promoted to the <g> by this function. - This is handled by moveCommonAttributesToParentGroup. - - If all children have a common attribute, an extra <g> is not created. - - This function acts recursively on the given element. - """ - num = 0 - global numElemsRemoved - - # TODO perhaps all of the Presentation attributes in http://www.w3.org/TR/SVG/struct.html#GElement - # could be added here - # Cyn: These attributes are the same as in moveAttributesToParentGroup, and must always be - for curAttr in ['clip-rule', - 'display-align', - 'fill', 'fill-opacity', 'fill-rule', - 'font', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', - 'font-style', 'font-variant', 'font-weight', - 'letter-spacing', - 'pointer-events', 'shape-rendering', - 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', - 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', - 'text-anchor', 'text-decoration', 'text-rendering', 'visibility', - 'word-spacing', 'writing-mode']: - # Iterate through the children in reverse order, so item(i) for - # items we have yet to visit still returns the correct nodes. - curChild = elem.childNodes.length - 1 - while curChild >= 0: - childNode = elem.childNodes.item(curChild) - - if childNode.nodeType == 1 and childNode.getAttribute(curAttr) != '': - # We're in a possible run! Track the value and run length. - value = childNode.getAttribute(curAttr) - runStart, runEnd = curChild, curChild - # Run elements includes only element tags, no whitespace/comments/etc. - # Later, we calculate a run length which includes these. - runElements = 1 - - # Backtrack to get all the nodes having the same - # attribute value, preserving any nodes in-between. - while runStart > 0: - nextNode = elem.childNodes.item(runStart - 1) - if nextNode.nodeType == 1: - if nextNode.getAttribute(curAttr) != value: break - else: - runElements += 1 - runStart -= 1 - else: runStart -= 1 - - if runElements >= 3: - # Include whitespace/comment/etc. nodes in the run. - while runEnd < elem.childNodes.length - 1: - if elem.childNodes.item(runEnd + 1).nodeType == 1: break - else: runEnd += 1 - - runLength = runEnd - runStart + 1 - if runLength == elem.childNodes.length: # Every child has this - # If the current parent is a <g> already, - if elem.nodeName == 'g' and elem.namespaceURI == NS['SVG']: - # do not act altogether on this attribute; all the - # children have it in common. - # Let moveCommonAttributesToParentGroup do it. - curChild = -1 - continue - # otherwise, it might be an <svg> element, and - # even if all children have the same attribute value, - # it's going to be worth making the <g> since - # <svg> doesn't support attributes like 'stroke'. - # Fall through. - - # Create a <g> element from scratch. - # We need the Document for this. - document = elem.ownerDocument - group = document.createElementNS(NS['SVG'], 'g') - # Move the run of elements to the group. - # a) ADD the nodes to the new group. - group.childNodes[:] = elem.childNodes[runStart:runEnd + 1] - for child in group.childNodes: - child.parentNode = group - # b) REMOVE the nodes from the element. - elem.childNodes[runStart:runEnd + 1] = [] - # Include the group in elem's children. - elem.childNodes.insert(runStart, group) - group.parentNode = elem - num += 1 - curChild = runStart - 1 - numElemsRemoved -= 1 - else: - curChild -= 1 - else: - curChild -= 1 - - # each child gets the same treatment, recursively - for childNode in elem.childNodes: - if childNode.nodeType == 1: - num += createGroupsForCommonAttributes(childNode) - - return num - -def removeUnusedAttributesOnParent(elem): - """ - This recursively calls this function on all children of the element passed in, - then removes any unused attributes on this elem if none of the children inherit it - """ - num = 0 - - childElements = [] - # recurse first into the children (depth-first) - for child in elem.childNodes: - if child.nodeType == 1: - childElements.append(child) - num += removeUnusedAttributesOnParent(child) - - # only process the children if there are more than one element - if len(childElements) <= 1: return num - - # get all attribute values on this parent - attrList = elem.attributes - unusedAttrs = {} - for num in xrange(attrList.length): - attr = attrList.item(num) - if attr.nodeName in ['clip-rule', - 'display-align', - 'fill', 'fill-opacity', 'fill-rule', - 'font', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', - 'font-style', 'font-variant', 'font-weight', - 'letter-spacing', - 'pointer-events', 'shape-rendering', - 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', - 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', - 'text-anchor', 'text-decoration', 'text-rendering', 'visibility', - 'word-spacing', 'writing-mode']: - unusedAttrs[attr.nodeName] = attr.nodeValue - - # for each child, if at least one child inherits the parent's attribute, then remove - for childNum in xrange(len(childElements)): - child = childElements[childNum] - inheritedAttrs = [] - for name in unusedAttrs.keys(): - val = child.getAttribute(name) - if val == '' or val == None or val == 'inherit': - inheritedAttrs.append(name) - for a in inheritedAttrs: - del unusedAttrs[a] - - # unusedAttrs now has all the parent attributes that are unused - for name in unusedAttrs.keys(): - elem.removeAttribute(name) - num += 1 - - return num - -def removeDuplicateGradientStops(doc): - global numElemsRemoved - num = 0 - - for gradType in ['linearGradient', 'radialGradient']: - for grad in doc.getElementsByTagName(gradType): - stops = {} - stopsToRemove = [] - for stop in grad.getElementsByTagName('stop'): - # convert percentages into a floating point number - offsetU = SVGLength(stop.getAttribute('offset')) - if offsetU.units == Unit.PCT: - offset = offsetU.value / 100.0 - elif offsetU.units == Unit.NONE: - offset = offsetU.value - else: - offset = 0 - # set the stop offset value to the integer or floating point equivalent - if int(offset) == offset: stop.setAttribute('offset', str(int(offset))) - else: stop.setAttribute('offset', str(offset)) - - color = stop.getAttribute('stop-color') - opacity = stop.getAttribute('stop-opacity') - style = stop.getAttribute('style') - if stops.has_key(offset) : - oldStop = stops[offset] - if oldStop[0] == color and oldStop[1] == opacity and oldStop[2] == style: - stopsToRemove.append(stop) - stops[offset] = [color, opacity, style] - - for stop in stopsToRemove: - stop.parentNode.removeChild(stop) - num += 1 - numElemsRemoved += 1 - - # linear gradients - return num - -def collapseSinglyReferencedGradients(doc): - global numElemsRemoved - num = 0 - - identifiedElements = findElementsWithId(doc.documentElement) - - # make sure to reset the ref'ed ids for when we are running this in testscour - for rid,nodeCount in findReferencedElements(doc.documentElement).iteritems(): - count = nodeCount[0] - nodes = nodeCount[1] - # Make sure that there's actually a defining element for the current ID name. - # (Cyn: I've seen documents with #id references but no element with that ID!) - if count == 1 and rid in identifiedElements: - elem = identifiedElements[rid] - if elem != None and elem.nodeType == 1 and elem.nodeName in ['linearGradient', 'radialGradient'] \ - and elem.namespaceURI == NS['SVG']: - # found a gradient that is referenced by only 1 other element - refElem = nodes[0] - if refElem.nodeType == 1 and refElem.nodeName in ['linearGradient', 'radialGradient'] \ - and refElem.namespaceURI == NS['SVG']: - # elem is a gradient referenced by only one other gradient (refElem) - - # add the stops to the referencing gradient (this removes them from elem) - if len(refElem.getElementsByTagName('stop')) == 0: - stopsToAdd = elem.getElementsByTagName('stop') - for stop in stopsToAdd: - refElem.appendChild(stop) - - # adopt the gradientUnits, spreadMethod, gradientTransform attributes if - # they are unspecified on refElem - for attr in ['gradientUnits','spreadMethod','gradientTransform']: - if refElem.getAttribute(attr) == '' and not elem.getAttribute(attr) == '': - refElem.setAttributeNS(None, attr, elem.getAttribute(attr)) - - # if both are radialGradients, adopt elem's fx,fy,cx,cy,r attributes if - # they are unspecified on refElem - if elem.nodeName == 'radialGradient' and refElem.nodeName == 'radialGradient': - for attr in ['fx','fy','cx','cy','r']: - if refElem.getAttribute(attr) == '' and not elem.getAttribute(attr) == '': - refElem.setAttributeNS(None, attr, elem.getAttribute(attr)) - - # if both are linearGradients, adopt elem's x1,y1,x2,y2 attributes if - # they are unspecified on refElem - if elem.nodeName == 'linearGradient' and refElem.nodeName == 'linearGradient': - for attr in ['x1','y1','x2','y2']: - if refElem.getAttribute(attr) == '' and not elem.getAttribute(attr) == '': - refElem.setAttributeNS(None, attr, elem.getAttribute(attr)) - - # now remove the xlink:href from refElem - refElem.removeAttributeNS(NS['XLINK'], 'href') - - # now delete elem - elem.parentNode.removeChild(elem) - numElemsRemoved += 1 - num += 1 - return num - -def removeDuplicateGradients(doc): - global numElemsRemoved - num = 0 - - gradientsToRemove = {} - duplicateToMaster = {} - - for gradType in ['linearGradient', 'radialGradient']: - grads = doc.getElementsByTagName(gradType) - for grad in grads: - # TODO: should slice grads from 'grad' here to optimize - for ograd in grads: - # do not compare gradient to itself - if grad == ograd: continue - - # compare grad to ograd (all properties, then all stops) - # if attributes do not match, go to next gradient - someGradAttrsDoNotMatch = False - for attr in ['gradientUnits','spreadMethod','gradientTransform','x1','y1','x2','y2','cx','cy','fx','fy','r']: - if grad.getAttribute(attr) != ograd.getAttribute(attr): - someGradAttrsDoNotMatch = True - break; - - if someGradAttrsDoNotMatch: continue - - # compare xlink:href values too - if grad.getAttributeNS(NS['XLINK'], 'href') != ograd.getAttributeNS(NS['XLINK'], 'href'): - continue - - # all gradient properties match, now time to compare stops - stops = grad.getElementsByTagName('stop') - ostops = ograd.getElementsByTagName('stop') - - if stops.length != ostops.length: continue - - # now compare stops - stopsNotEqual = False - for i in xrange(stops.length): - if stopsNotEqual: break - stop = stops.item(i) - ostop = ostops.item(i) - for attr in ['offset', 'stop-color', 'stop-opacity', 'style']: - if stop.getAttribute(attr) != ostop.getAttribute(attr): - stopsNotEqual = True - break - if stopsNotEqual: continue - - # ograd is a duplicate of grad, we schedule it to be removed UNLESS - # ograd is ALREADY considered a 'master' element - if not gradientsToRemove.has_key(ograd): - if not duplicateToMaster.has_key(ograd): - if not gradientsToRemove.has_key(grad): - gradientsToRemove[grad] = [] - gradientsToRemove[grad].append( ograd ) - duplicateToMaster[ograd] = grad - - # get a collection of all elements that are referenced and their referencing elements - referencedIDs = findReferencedElements(doc.documentElement) - for masterGrad in gradientsToRemove.keys(): - master_id = masterGrad.getAttribute('id') -# print 'master='+master_id - for dupGrad in gradientsToRemove[masterGrad]: - # if the duplicate gradient no longer has a parent that means it was - # already re-mapped to another master gradient - if not dupGrad.parentNode: continue - dup_id = dupGrad.getAttribute('id') -# print 'dup='+dup_id -# print referencedIDs[dup_id] - # for each element that referenced the gradient we are going to remove - for elem in referencedIDs[dup_id][1]: - # find out which attribute referenced the duplicate gradient - for attr in ['fill', 'stroke']: - v = elem.getAttribute(attr) - if v == 'url(#'+dup_id+')' or v == 'url("#'+dup_id+'")' or v == "url('#"+dup_id+"')": - elem.setAttribute(attr, 'url(#'+master_id+')') - if elem.getAttributeNS(NS['XLINK'], 'href') == '#'+dup_id: - elem.setAttributeNS(NS['XLINK'], 'href', '#'+master_id) - styles = _getStyle(elem) - for style in styles: - v = styles[style] - if v == 'url(#'+dup_id+')' or v == 'url("#'+dup_id+'")' or v == "url('#"+dup_id+"')": - styles[style] = 'url(#'+master_id+')' - _setStyle(elem, styles) - - # now that all referencing elements have been re-mapped to the master - # it is safe to remove this gradient from the document - dupGrad.parentNode.removeChild(dupGrad) - numElemsRemoved += 1 - num += 1 - return num - -def _getStyle(node): - u"""Returns the style attribute of a node as a dictionary.""" - if node.nodeType == 1 and len(node.getAttribute('style')) > 0 : - styleMap = { } - rawStyles = node.getAttribute('style').split(';') - for style in rawStyles: - propval = style.split(':') - if len(propval) == 2 : - styleMap[propval[0].strip()] = propval[1].strip() - return styleMap - else: - return {} - -def _setStyle(node, styleMap): - u"""Sets the style attribute of a node to the dictionary ``styleMap``.""" - fixedStyle = ';'.join([prop + ':' + styleMap[prop] for prop in styleMap.keys()]) - if fixedStyle != '' : - node.setAttribute('style', fixedStyle) - elif node.getAttribute('style'): - node.removeAttribute('style') - return node - -def repairStyle(node, options): - num = 0 - styleMap = _getStyle(node) - if styleMap: - - # I've seen this enough to know that I need to correct it: - # fill: url(#linearGradient4918) rgb(0, 0, 0); - for prop in ['fill', 'stroke'] : - if styleMap.has_key(prop) : - chunk = styleMap[prop].split(') ') - if len(chunk) == 2 and (chunk[0][:5] == 'url(#' or chunk[0][:6] == 'url("#' or chunk[0][:6] == "url('#") and chunk[1] == 'rgb(0, 0, 0)' : - styleMap[prop] = chunk[0] + ')' - num += 1 - - # Here is where we can weed out unnecessary styles like: - # opacity:1 - if styleMap.has_key('opacity') : - opacity = float(styleMap['opacity']) - # if opacity='0' then all fill and stroke properties are useless, remove them - if opacity == 0.0 : - for uselessStyle in ['fill', 'fill-opacity', 'fill-rule', 'stroke', 'stroke-linejoin', - 'stroke-opacity', 'stroke-miterlimit', 'stroke-linecap', 'stroke-dasharray', - 'stroke-dashoffset', 'stroke-opacity'] : - if styleMap.has_key(uselessStyle): - del styleMap[uselessStyle] - num += 1 - - # if stroke:none, then remove all stroke-related properties (stroke-width, etc) - # TODO: should also detect if the computed value of this element is stroke="none" - if styleMap.has_key('stroke') and styleMap['stroke'] == 'none' : - for strokestyle in [ 'stroke-width', 'stroke-linejoin', 'stroke-miterlimit', - 'stroke-linecap', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-opacity'] : - if styleMap.has_key(strokestyle) : - del styleMap[strokestyle] - num += 1 - # TODO: This is actually a problem if a parent element has a specified stroke - # we need to properly calculate computed values - del styleMap['stroke'] - - # if fill:none, then remove all fill-related properties (fill-rule, etc) - if styleMap.has_key('fill') and styleMap['fill'] == 'none' : - for fillstyle in [ 'fill-rule', 'fill-opacity' ] : - if styleMap.has_key(fillstyle) : - del styleMap[fillstyle] - num += 1 - - # fill-opacity: 0 - if styleMap.has_key('fill-opacity') : - fillOpacity = float(styleMap['fill-opacity']) - if fillOpacity == 0.0 : - for uselessFillStyle in [ 'fill', 'fill-rule' ] : - if styleMap.has_key(uselessFillStyle): - del styleMap[uselessFillStyle] - num += 1 - - # stroke-opacity: 0 - if styleMap.has_key('stroke-opacity') : - strokeOpacity = float(styleMap['stroke-opacity']) - if strokeOpacity == 0.0 : - for uselessStrokeStyle in [ 'stroke', 'stroke-width', 'stroke-linejoin', 'stroke-linecap', - 'stroke-dasharray', 'stroke-dashoffset' ] : - if styleMap.has_key(uselessStrokeStyle): - del styleMap[uselessStrokeStyle] - num += 1 - - # stroke-width: 0 - if styleMap.has_key('stroke-width') : - strokeWidth = SVGLength(styleMap['stroke-width']) - if strokeWidth.value == 0.0 : - for uselessStrokeStyle in [ 'stroke', 'stroke-linejoin', 'stroke-linecap', - 'stroke-dasharray', 'stroke-dashoffset', 'stroke-opacity' ] : - if styleMap.has_key(uselessStrokeStyle): - del styleMap[uselessStrokeStyle] - num += 1 - - # remove font properties for non-text elements - # I've actually observed this in real SVG content - if not mayContainTextNodes(node): - for fontstyle in [ 'font-family', 'font-size', 'font-stretch', 'font-size-adjust', - 'font-style', 'font-variant', 'font-weight', - 'letter-spacing', 'line-height', 'kerning', - 'text-align', 'text-anchor', 'text-decoration', - 'text-rendering', 'unicode-bidi', - 'word-spacing', 'writing-mode'] : - if styleMap.has_key(fontstyle) : - del styleMap[fontstyle] - num += 1 - - # remove inkscape-specific styles - # TODO: need to get a full list of these - for inkscapeStyle in ['-inkscape-font-specification']: - if styleMap.has_key(inkscapeStyle): - del styleMap[inkscapeStyle] - num += 1 - - if styleMap.has_key('overflow') : - # overflow specified on element other than svg, marker, pattern - if not node.nodeName in ['svg','marker','pattern']: - del styleMap['overflow'] - num += 1 - # it is a marker, pattern or svg - # as long as this node is not the document <svg>, then only - # remove overflow='hidden'. See - # http://www.w3.org/TR/2010/WD-SVG11-20100622/masking.html#OverflowProperty - elif node != node.ownerDocument.documentElement: - if styleMap['overflow'] == 'hidden': - del styleMap['overflow'] - num += 1 - # else if outer svg has a overflow="visible", we can remove it - elif styleMap['overflow'] == 'visible': - del styleMap['overflow'] - num += 1 - - # now if any of the properties match known SVG attributes we prefer attributes - # over style so emit them and remove them from the style map - if options.style_to_xml: - for propName in styleMap.keys() : - if propName in svgAttributes : - node.setAttribute(propName, styleMap[propName]) - del styleMap[propName] - - _setStyle(node, styleMap) - - # recurse for our child elements - for child in node.childNodes : - num += repairStyle(child,options) - - return num - -def mayContainTextNodes(node): - """ - Returns True if the passed-in node is probably a text element, or at least - one of its descendants is probably a text element. - - If False is returned, it is guaranteed that the passed-in node has no - business having text-based attributes. - - If True is returned, the passed-in node should not have its text-based - attributes removed. - """ - # Cached result of a prior call? - try: - return node.mayContainTextNodes - except AttributeError: - pass - - result = True # Default value - # Comment, text and CDATA nodes don't have attributes and aren't containers - if node.nodeType != 1: - result = False - # Non-SVG elements? Unknown elements! - elif node.namespaceURI != NS['SVG']: - result = True - # Blacklisted elements. Those are guaranteed not to be text elements. - elif node.nodeName in ['rect', 'circle', 'ellipse', 'line', 'polygon', - 'polyline', 'path', 'image', 'stop']: - result = False - # Group elements. If we're missing any here, the default of True is used. - elif node.nodeName in ['g', 'clipPath', 'marker', 'mask', 'pattern', - 'linearGradient', 'radialGradient', 'symbol']: - result = False - for child in node.childNodes: - if mayContainTextNodes(child): - result = True - # Everything else should be considered a future SVG-version text element - # at best, or an unknown element at worst. result will stay True. - - # Cache this result before returning it. - node.mayContainTextNodes = result - return result - -def taint(taintedSet, taintedAttribute): - u"""Adds an attribute to a set of attributes. - - Related attributes are also included.""" - taintedSet.add(taintedAttribute) - if taintedAttribute == 'marker': - taintedSet |= set(['marker-start', 'marker-mid', 'marker-end']) - if taintedAttribute in ['marker-start', 'marker-mid', 'marker-end']: - taintedSet.add('marker') - return taintedSet - -def removeDefaultAttributeValues(node, options, tainted=set()): - u"""'tainted' keeps a set of attributes defined in parent nodes. - - For such attributes, we don't delete attributes with default values.""" - num = 0 - if node.nodeType != 1: return 0 - - # gradientUnits: objectBoundingBox - if node.getAttribute('gradientUnits') == 'objectBoundingBox': - node.removeAttribute('gradientUnits') - num += 1 - - # spreadMethod: pad - if node.getAttribute('spreadMethod') == 'pad': - node.removeAttribute('spreadMethod') - num += 1 - - # x1: 0% - if node.getAttribute('x1') != '': - x1 = SVGLength(node.getAttribute('x1')) - if x1.value == 0: - node.removeAttribute('x1') - num += 1 - - # y1: 0% - if node.getAttribute('y1') != '': - y1 = SVGLength(node.getAttribute('y1')) - if y1.value == 0: - node.removeAttribute('y1') - num += 1 - - # x2: 100% - if node.getAttribute('x2') != '': - x2 = SVGLength(node.getAttribute('x2')) - if (x2.value == 100 and x2.units == Unit.PCT) or (x2.value == 1 and x2.units == Unit.NONE): - node.removeAttribute('x2') - num += 1 - - # y2: 0% - if node.getAttribute('y2') != '': - y2 = SVGLength(node.getAttribute('y2')) - if y2.value == 0: - node.removeAttribute('y2') - num += 1 - - # fx: equal to rx - if node.getAttribute('fx') != '': - if node.getAttribute('fx') == node.getAttribute('cx'): - node.removeAttribute('fx') - num += 1 - - # fy: equal to ry - if node.getAttribute('fy') != '': - if node.getAttribute('fy') == node.getAttribute('cy'): - node.removeAttribute('fy') - num += 1 - - # cx: 50% - if node.getAttribute('cx') != '': - cx = SVGLength(node.getAttribute('cx')) - if (cx.value == 50 and cx.units == Unit.PCT) or (cx.value == 0.5 and cx.units == Unit.NONE): - node.removeAttribute('cx') - num += 1 - - # cy: 50% - if node.getAttribute('cy') != '': - cy = SVGLength(node.getAttribute('cy')) - if (cy.value == 50 and cy.units == Unit.PCT) or (cy.value == 0.5 and cy.units == Unit.NONE): - node.removeAttribute('cy') - num += 1 - - # r: 50% - if node.getAttribute('r') != '': - r = SVGLength(node.getAttribute('r')) - if (r.value == 50 and r.units == Unit.PCT) or (r.value == 0.5 and r.units == Unit.NONE): - node.removeAttribute('r') - num += 1 - - # Summarily get rid of some more attributes - attributes = [node.attributes.item(i).nodeName - for i in range(node.attributes.length)] - for attribute in attributes: - if attribute not in tainted: - if attribute in default_attributes.keys(): - if node.getAttribute(attribute) == default_attributes[attribute]: - node.removeAttribute(attribute) - num += 1 - else: - tainted = taint(tainted, attribute) - # These attributes might also occur as styles - styles = _getStyle(node) - for attribute in styles.keys(): - if attribute not in tainted: - if attribute in default_attributes.keys(): - if styles[attribute] == default_attributes[attribute]: - del styles[attribute] - num += 1 - else: - tainted = taint(tainted, attribute) - _setStyle(node, styles) - - # recurse for our child elements - for child in node.childNodes : - num += removeDefaultAttributeValues(child, options, tainted.copy()) - - return num - -rgb = re.compile(r"\s*rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*") -rgbp = re.compile(r"\s*rgb\(\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*\)\s*") -def convertColor(value): - """ - Converts the input color string and returns a #RRGGBB (or #RGB if possible) string - """ - s = value - - if s in colors.keys(): - s = colors[s] - - rgbpMatch = rgbp.match(s) - if rgbpMatch != None : - r = int(float(rgbpMatch.group(1)) * 255.0 / 100.0) - g = int(float(rgbpMatch.group(2)) * 255.0 / 100.0) - b = int(float(rgbpMatch.group(3)) * 255.0 / 100.0) - s = '#%02x%02x%02x' % (r, g, b) - else: - rgbMatch = rgb.match(s) - if rgbMatch != None : - r = int( rgbMatch.group(1) ) - g = int( rgbMatch.group(2) ) - b = int( rgbMatch.group(3) ) - s = '#%02x%02x%02x' % (r, g, b) - - if s[0] == '#': - s = s.lower() - if len(s)==7 and s[1]==s[2] and s[3]==s[4] and s[5]==s[6]: - s = '#'+s[1]+s[3]+s[5] - - return s - -def convertColors(element) : - """ - Recursively converts all color properties into #RRGGBB format if shorter - """ - numBytes = 0 - - if element.nodeType != 1: return 0 - - # set up list of color attributes for each element type - attrsToConvert = [] - if element.nodeName in ['rect', 'circle', 'ellipse', 'polygon', \ - 'line', 'polyline', 'path', 'g', 'a']: - attrsToConvert = ['fill', 'stroke'] - elif element.nodeName in ['stop']: - attrsToConvert = ['stop-color'] - elif element.nodeName in ['solidColor']: - attrsToConvert = ['solid-color'] - - # now convert all the color formats - styles = _getStyle(element) - for attr in attrsToConvert: - oldColorValue = element.getAttribute(attr) - if oldColorValue != '': - newColorValue = convertColor(oldColorValue) - oldBytes = len(oldColorValue) - newBytes = len(newColorValue) - if oldBytes > newBytes: - element.setAttribute(attr, newColorValue) - numBytes += (oldBytes - len(element.getAttribute(attr))) - # colors might also hide in styles - if attr in styles.keys(): - oldColorValue = styles[attr] - newColorValue = convertColor(oldColorValue) - oldBytes = len(oldColorValue) - newBytes = len(newColorValue) - if oldBytes > newBytes: - styles[attr] = newColorValue - numBytes += (oldBytes - len(element.getAttribute(attr))) - _setStyle(element, styles) - - # now recurse for our child elements - for child in element.childNodes : - numBytes += convertColors(child) - - return numBytes - -# TODO: go over what this method does and see if there is a way to optimize it -# TODO: go over the performance of this method and see if I can save memory/speed by -# reusing data structures, etc -def cleanPath(element, options) : - """ - Cleans the path string (d attribute) of the element - """ - global numBytesSavedInPathData - global numPathSegmentsReduced - global numCurvesStraightened - - # this gets the parser object from svg_regex.py - oldPathStr = element.getAttribute('d') - path = svg_parser.parse(oldPathStr) - - # This determines whether the stroke has round linecaps. If it does, - # we do not want to collapse empty segments, as they are actually rendered. - withRoundLineCaps = element.getAttribute('stroke-linecap') == 'round' - - # The first command must be a moveto, and whether it's relative (m) - # or absolute (M), the first set of coordinates *is* absolute. So - # the first iteration of the loop below will get x,y and startx,starty. - - # convert absolute coordinates into relative ones. - # Reuse the data structure 'path', since we're not adding or removing subcommands. - # Also reuse the coordinate lists since we're not adding or removing any. - for pathIndex in xrange(0, len(path)): - cmd, data = path[pathIndex] # Changes to cmd don't get through to the data structure - i = 0 - # adjust abs to rel - # only the A command has some values that we don't want to adjust (radii, rotation, flags) - if cmd == 'A': - for i in xrange(i, len(data), 7): - data[i+5] -= x - data[i+6] -= y - x += data[i+5] - y += data[i+6] - path[pathIndex] = ('a', data) - elif cmd == 'a': - x += sum(data[5::7]) - y += sum(data[6::7]) - elif cmd == 'H': - for i in xrange(i, len(data)): - data[i] -= x - x += data[i] - path[pathIndex] = ('h', data) - elif cmd == 'h': - x += sum(data) - elif cmd == 'V': - for i in xrange(i, len(data)): - data[i] -= y - y += data[i] - path[pathIndex] = ('v', data) - elif cmd == 'v': - y += sum(data) - elif cmd == 'M': - startx, starty = data[0], data[1] - # If this is a path starter, don't convert its first - # coordinate to relative; that would just make it (0, 0) - if pathIndex != 0: - data[0] -= x - data[1] -= y - - x, y = startx, starty - i = 2 - for i in xrange(i, len(data), 2): - data[i] -= x - data[i+1] -= y - x += data[i] - y += data[i+1] - path[pathIndex] = ('m', data) - elif cmd in ['L','T']: - for i in xrange(i, len(data), 2): - data[i] -= x - data[i+1] -= y - x += data[i] - y += data[i+1] - path[pathIndex] = (cmd.lower(), data) - elif cmd in ['m']: - if pathIndex == 0: - # START OF PATH - this is an absolute moveto - # followed by relative linetos - startx, starty = data[0], data[1] - x, y = startx, starty - i = 2 - else: - startx = x + data[0] - starty = y + data[1] - for i in xrange(i, len(data), 2): - x += data[i] - y += data[i+1] - elif cmd in ['l','t']: - x += sum(data[0::2]) - y += sum(data[1::2]) - elif cmd in ['S','Q']: - for i in xrange(i, len(data), 4): - data[i] -= x - data[i+1] -= y - data[i+2] -= x - data[i+3] -= y - x += data[i+2] - y += data[i+3] - path[pathIndex] = (cmd.lower(), data) - elif cmd in ['s','q']: - x += sum(data[2::4]) - y += sum(data[3::4]) - elif cmd == 'C': - for i in xrange(i, len(data), 6): - data[i] -= x - data[i+1] -= y - data[i+2] -= x - data[i+3] -= y - data[i+4] -= x - data[i+5] -= y - x += data[i+4] - y += data[i+5] - path[pathIndex] = ('c', data) - elif cmd == 'c': - x += sum(data[4::6]) - y += sum(data[5::6]) - elif cmd in ['z','Z']: - x, y = startx, starty - path[pathIndex] = ('z', data) - - # remove empty segments - # Reuse the data structure 'path' and the coordinate lists, even if we're - # deleting items, because these deletions are relatively cheap. - if not withRoundLineCaps: - for pathIndex in xrange(0, len(path)): - cmd, data = path[pathIndex] - i = 0 - if cmd in ['m','l','t']: - if cmd == 'm': - # remove m0,0 segments - if pathIndex > 0 and data[0] == data[i+1] == 0: - # 'm0,0 x,y' can be replaces with 'lx,y', - # except the first m which is a required absolute moveto - path[pathIndex] = ('l', data[2:]) - numPathSegmentsReduced += 1 - else: # else skip move coordinate - i = 2 - while i < len(data): - if data[i] == data[i+1] == 0: - del data[i:i+2] - numPathSegmentsReduced += 1 - else: - i += 2 - elif cmd == 'c': - while i < len(data): - if data[i] == data[i+1] == data[i+2] == data[i+3] == data[i+4] == data[i+5] == 0: - del data[i:i+6] - numPathSegmentsReduced += 1 - else: - i += 6 - elif cmd == 'a': - while i < len(data): - if data[i+5] == data[i+6] == 0: - del data[i:i+7] - numPathSegmentsReduced += 1 - else: - i += 7 - elif cmd == 'q': - while i < len(data): - if data[i] == data[i+1] == data[i+2] == data[i+3] == 0: - del data[i:i+4] - numPathSegmentsReduced += 1 - else: - i += 4 - elif cmd in ['h','v']: - oldLen = len(data) - path[pathIndex] = (cmd, [coord for coord in data if coord != 0]) - numPathSegmentsReduced += len(path[pathIndex][1]) - oldLen - - # fixup: Delete subcommands having no coordinates. - path = [elem for elem in path if len(elem[1]) > 0 or elem[0] == 'z'] - - # convert straight curves into lines - newPath = [path[0]] - for (cmd,data) in path[1:]: - i = 0 - newData = data - if cmd == 'c': - newData = [] - while i < len(data): - # since all commands are now relative, we can think of previous point as (0,0) - # and new point (dx,dy) is (data[i+4],data[i+5]) - # eqn of line will be y = (dy/dx)*x or if dx=0 then eqn of line is x=0 - (p1x,p1y) = (data[i],data[i+1]) - (p2x,p2y) = (data[i+2],data[i+3]) - dx = data[i+4] - dy = data[i+5] - - foundStraightCurve = False - - if dx == 0: - if p1x == 0 and p2x == 0: - foundStraightCurve = True - else: - m = dy/dx - if p1y == m*p1x and p2y == m*p2x: - foundStraightCurve = True - - if foundStraightCurve: - # flush any existing curve coords first - if newData: - newPath.append( (cmd,newData) ) - newData = [] - # now create a straight line segment - newPath.append( ('l', [dx,dy]) ) - numCurvesStraightened += 1 - else: - newData.extend(data[i:i+6]) - - i += 6 - if newData or cmd == 'z' or cmd == 'Z': - newPath.append( (cmd,newData) ) - path = newPath - - # collapse all consecutive commands of the same type into one command - prevCmd = '' - prevData = [] - newPath = [] - for (cmd,data) in path: - # flush the previous command if it is not the same type as the current command - if prevCmd != '': - if cmd != prevCmd or cmd == 'm': - newPath.append( (prevCmd, prevData) ) - prevCmd = '' - prevData = [] - - # if the previous and current commands are the same type, - # or the previous command is moveto and the current is lineto, collapse, - # but only if they are not move commands (since move can contain implicit lineto commands) - if (cmd == prevCmd or (cmd == 'l' and prevCmd == 'm')) and cmd != 'm': - prevData.extend(data) - - # save last command and data - else: - prevCmd = cmd - prevData = data - # flush last command and data - if prevCmd != '': - newPath.append( (prevCmd, prevData) ) - path = newPath - - # convert to shorthand path segments where possible - newPath = [] - for (cmd,data) in path: - # convert line segments into h,v where possible - if cmd == 'l': - i = 0 - lineTuples = [] - while i < len(data): - if data[i] == 0: - # vertical - if lineTuples: - # flush the existing line command - newPath.append( ('l', lineTuples) ) - lineTuples = [] - # append the v and then the remaining line coords - newPath.append( ('v', [data[i+1]]) ) - numPathSegmentsReduced += 1 - elif data[i+1] == 0: - if lineTuples: - # flush the line command, then append the h and then the remaining line coords - newPath.append( ('l', lineTuples) ) - lineTuples = [] - newPath.append( ('h', [data[i]]) ) - numPathSegmentsReduced += 1 - else: - lineTuples.extend(data[i:i+2]) - i += 2 - if lineTuples: - newPath.append( ('l', lineTuples) ) - # also handle implied relative linetos - elif cmd == 'm': - i = 2 - lineTuples = [data[0], data[1]] - while i < len(data): - if data[i] == 0: - # vertical - if lineTuples: - # flush the existing m/l command - newPath.append( (cmd, lineTuples) ) - lineTuples = [] - cmd = 'l' # dealing with linetos now - # append the v and then the remaining line coords - newPath.append( ('v', [data[i+1]]) ) - numPathSegmentsReduced += 1 - elif data[i+1] == 0: - if lineTuples: - # flush the m/l command, then append the h and then the remaining line coords - newPath.append( (cmd, lineTuples) ) - lineTuples = [] - cmd = 'l' # dealing with linetos now - newPath.append( ('h', [data[i]]) ) - numPathSegmentsReduced += 1 - else: - lineTuples.extend(data[i:i+2]) - i += 2 - if lineTuples: - newPath.append( (cmd, lineTuples) ) - # convert Bézier curve segments into s where possible - elif cmd == 'c': - bez_ctl_pt = (0,0) - i = 0 - curveTuples = [] - while i < len(data): - # rotate by 180deg means negate both coordinates - # if the previous control point is equal then we can substitute a - # shorthand bezier command - if bez_ctl_pt[0] == data[i] and bez_ctl_pt[1] == data[i+1]: - if curveTuples: - newPath.append( ('c', curveTuples) ) - curveTuples = [] - # append the s command - newPath.append( ('s', [data[i+2], data[i+3], data[i+4], data[i+5]]) ) - numPathSegmentsReduced += 1 - else: - j = 0 - while j <= 5: - curveTuples.append(data[i+j]) - j += 1 - - # set up control point for next curve segment - bez_ctl_pt = (data[i+4]-data[i+2], data[i+5]-data[i+3]) - i += 6 - - if curveTuples: - newPath.append( ('c', curveTuples) ) - # convert quadratic curve segments into t where possible - elif cmd == 'q': - quad_ctl_pt = (0,0) - i = 0 - curveTuples = [] - while i < len(data): - if quad_ctl_pt[0] == data[i] and quad_ctl_pt[1] == data[i+1]: - if curveTuples: - newPath.append( ('q', curveTuples) ) - curveTuples = [] - # append the t command - newPath.append( ('t', [data[i+2], data[i+3]]) ) - numPathSegmentsReduced += 1 - else: - j = 0; - while j <= 3: - curveTuples.append(data[i+j]) - j += 1 - - quad_ctl_pt = (data[i+2]-data[i], data[i+3]-data[i+1]) - i += 4 - - if curveTuples: - newPath.append( ('q', curveTuples) ) - else: - newPath.append( (cmd, data) ) - path = newPath - - # for each h or v, collapse unnecessary coordinates that run in the same direction - # i.e. "h-100-100" becomes "h-200" but "h300-100" does not change - # Reuse the data structure 'path', since we're not adding or removing subcommands. - # Also reuse the coordinate lists, even if we're deleting items, because these - # deletions are relatively cheap. - for pathIndex in xrange(1, len(path)): - cmd, data = path[pathIndex] - if cmd in ['h','v'] and len(data) > 1: - coordIndex = 1 - while coordIndex < len(data): - if isSameSign(data[coordIndex - 1], data[coordIndex]): - data[coordIndex - 1] += data[coordIndex] - del data[coordIndex] - numPathSegmentsReduced += 1 - else: - coordIndex += 1 - - # it is possible that we have consecutive h, v, c, t commands now - # so again collapse all consecutive commands of the same type into one command - prevCmd = '' - prevData = [] - newPath = [path[0]] - for (cmd,data) in path[1:]: - # flush the previous command if it is not the same type as the current command - if prevCmd != '': - if cmd != prevCmd or cmd == 'm': - newPath.append( (prevCmd, prevData) ) - prevCmd = '' - prevData = [] - - # if the previous and current commands are the same type, collapse - if cmd == prevCmd and cmd != 'm': - prevData.extend(data) - - # save last command and data - else: - prevCmd = cmd - prevData = data - # flush last command and data - if prevCmd != '': - newPath.append( (prevCmd, prevData) ) - path = newPath - - newPathStr = serializePath(path, options) - numBytesSavedInPathData += ( len(oldPathStr) - len(newPathStr) ) - element.setAttribute('d', newPathStr) - -def parseListOfPoints(s): - """ - Parse string into a list of points. - - Returns a list of containing an even number of coordinate strings - """ - i = 0 - - # (wsp)? comma-or-wsp-separated coordinate pairs (wsp)? - # coordinate-pair = coordinate comma-or-wsp coordinate - # coordinate = sign? integer - # comma-wsp: (wsp+ comma? wsp*) | (comma wsp*) - ws_nums = re.split(r"\s*,?\s*", s.strip()) - nums = [] - - # also, if 100-100 is found, split it into two also - # <polygon points="100,-100,100-100,100-100-100,-100-100" /> - for i in xrange(len(ws_nums)): - negcoords = ws_nums[i].split("-") - - # this string didn't have any negative coordinates - if len(negcoords) == 1: - nums.append(negcoords[0]) - # we got negative coords - else: - for j in xrange(len(negcoords)): - if j == 0: - # first number could be positive - if negcoords[0] != '': - nums.append(negcoords[0]) - # but it could also be negative - elif len(nums) == 0: - nums.append('-' + negcoords[j]) - # otherwise all other strings will be negative - else: - # unless we accidentally split a number that was in scientific notation - # and had a negative exponent (500.00e-1) - prev = nums[len(nums)-1] - if prev[len(prev)-1] in ['e', 'E']: - nums[len(nums)-1] = prev + '-' + negcoords[j] - else: - nums.append( '-'+negcoords[j] ) - - # if we have an odd number of points, return empty - if len(nums) % 2 != 0: return [] - - # now resolve into Decimal values - i = 0 - while i < len(nums): - try: - nums[i] = getcontext().create_decimal(nums[i]) - nums[i + 1] = getcontext().create_decimal(nums[i + 1]) - except decimal.InvalidOperation: # one of the lengths had a unit or is an invalid number - return [] - - i += 2 - - return nums - -def cleanPolygon(elem, options): - """ - Remove unnecessary closing point of polygon points attribute - """ - global numPointsRemovedFromPolygon - - pts = parseListOfPoints(elem.getAttribute('points')) - N = len(pts)/2 - if N >= 2: - (startx,starty) = pts[:2] - (endx,endy) = pts[-2:] - if startx == endx and starty == endy: - del pts[-2:] - numPointsRemovedFromPolygon += 1 - elem.setAttribute('points', scourCoordinates(pts, options, True)) - -def cleanPolyline(elem, options): - """ - Scour the polyline points attribute - """ - pts = parseListOfPoints(elem.getAttribute('points')) - elem.setAttribute('points', scourCoordinates(pts, options, True)) - -def serializePath(pathObj, options): - """ - Reserializes the path data with some cleanups. - """ - # elliptical arc commands must have comma/wsp separating the coordinates - # this fixes an issue outlined in Fix https://bugs.launchpad.net/scour/+bug/412754 - return ''.join([cmd + scourCoordinates(data, options, (cmd == 'a')) for cmd, data in pathObj]) - -def serializeTransform(transformObj): - """ - Reserializes the transform data with some cleanups. - """ - return ' '.join( - [command + '(' + ' '.join( - [scourUnitlessLength(number) for number in numbers] - ) + ')' - for command, numbers in transformObj] - ) - -def scourCoordinates(data, options, forceCommaWsp = False): - """ - Serializes coordinate data with some cleanups: - - removes all trailing zeros after the decimal - - integerize coordinates if possible - - removes extraneous whitespace - - adds spaces between values in a subcommand if required (or if forceCommaWsp is True) - """ - if data != None: - newData = [] - c = 0 - previousCoord = '' - for coord in data: - scouredCoord = scourUnitlessLength(coord, needsRendererWorkaround=options.renderer_workaround) - # only need the comma if the current number starts with a digit - # (numbers can start with - without needing a comma before) - # or if forceCommaWsp is True - # or if this number starts with a dot and the previous number - # had *no* dot or exponent (so we can go like -5.5.5 for -5.5,0.5 - # and 4e4.5 for 40000,0.5) - if c > 0 and (forceCommaWsp - or scouredCoord[0].isdigit() - or (scouredCoord[0] == '.' and not ('.' in previousCoord or 'e' in previousCoord)) - ): - newData.append( ' ' ) - - # add the scoured coordinate to the path string - newData.append( scouredCoord ) - previousCoord = scouredCoord - c += 1 - - # What we need to do to work around GNOME bugs 548494, 563933 and - # 620565, which are being fixed and unfixed in Ubuntu, is - # to make sure that a dot doesn't immediately follow a command - # (so 'h50' and 'h0.5' are allowed, but not 'h.5'). - # Then, we need to add a space character after any coordinates - # having an 'e' (scientific notation), so as to have the exponent - # separate from the next number. - if options.renderer_workaround: - if len(newData) > 0: - for i in xrange(1, len(newData)): - if newData[i][0] == '-' and 'e' in newData[i - 1]: - newData[i - 1] += ' ' - return ''.join(newData) - else: - return ''.join(newData) - - return '' - -def scourLength(length): - """ - Scours a length. Accepts units. - """ - length = SVGLength(length) - - return scourUnitlessLength(length.value) + Unit.str(length.units) - -def scourUnitlessLength(length, needsRendererWorkaround=False): # length is of a numeric type - """ - Scours the numeric part of a length only. Does not accept units. - - This is faster than scourLength on elements guaranteed not to - contain units. - """ - # reduce to the proper number of digits - if not isinstance(length, Decimal): - length = getcontext().create_decimal(str(length)) - # if the value is an integer, it may still have .0[...] attached to it for some reason - # remove those - if int(length) == length: - length = getcontext().create_decimal(int(length)) - - # gather the non-scientific notation version of the coordinate. - # this may actually be in scientific notation if the value is - # sufficiently large or small, so this is a misnomer. - nonsci = unicode(length).lower().replace("e+", "e") - if not needsRendererWorkaround: - if len(nonsci) > 2 and nonsci[:2] == '0.': - nonsci = nonsci[1:] # remove the 0, leave the dot - elif len(nonsci) > 3 and nonsci[:3] == '-0.': - nonsci = '-' + nonsci[2:] # remove the 0, leave the minus and dot - - if len(nonsci) > 3: # avoid calling normalize unless strictly necessary - # and then the scientific notation version, with E+NUMBER replaced with - # just eNUMBER, since SVG accepts this. - sci = unicode(length.normalize()).lower().replace("e+", "e") - - if len(sci) < len(nonsci): return sci - else: return nonsci - else: return nonsci - -def reducePrecision(element) : - """ - Because opacities, letter spacings, stroke widths and all that don't need - to be preserved in SVG files with 9 digits of precision. - - Takes all of these attributes, in the given element node and its children, - and reduces their precision to the current Decimal context's precision. - Also checks for the attributes actually being lengths, not 'inherit', 'none' - or anything that isn't an SVGLength. - - Returns the number of bytes saved after performing these reductions. - """ - num = 0 - - styles = _getStyle(element) - for lengthAttr in ['opacity', 'flood-opacity', 'fill-opacity', - 'stroke-opacity', 'stop-opacity', 'stroke-miterlimit', - 'stroke-dashoffset', 'letter-spacing', 'word-spacing', - 'kerning', 'font-size-adjust', 'font-size', - 'stroke-width']: - val = element.getAttribute(lengthAttr) - if val != '': - valLen = SVGLength(val) - if valLen.units != Unit.INVALID: # not an absolute/relative size or inherit, can be % though - newVal = scourLength(val) - if len(newVal) < len(val): - num += len(val) - len(newVal) - element.setAttribute(lengthAttr, newVal) - # repeat for attributes hidden in styles - if lengthAttr in styles.keys(): - val = styles[lengthAttr] - valLen = SVGLength(val) - if valLen.units != Unit.INVALID: - newVal = scourLength(val) - if len(newVal) < len(val): - num += len(val) - len(newVal) - styles[lengthAttr] = newVal - _setStyle(element, styles) - - for child in element.childNodes: - if child.nodeType == 1: - num += reducePrecision(child) - - return num - -def optimizeAngle(angle): - """ - Because any rotation can be expressed within 360 degrees - of any given number, and since negative angles sometimes - are one character longer than corresponding positive angle, - we shorten the number to one in the range to [-90, 270[. - """ - # First, we put the new angle in the range ]-360, 360[. - # The modulo operator yields results with the sign of the - # divisor, so for negative dividends, we preserve the sign - # of the angle. - if angle < 0: angle %= -360 - else: angle %= 360 - # 720 degrees is unneccessary, as 360 covers all angles. - # As "-x" is shorter than "35x" and "-xxx" one character - # longer than positive angles <= 260, we constrain angle - # range to [-90, 270[ (or, equally valid: ]-100, 260]). - if angle >= 270: angle -= 360 - elif angle < -90: angle += 360 - return angle - - -def optimizeTransform(transform): - """ - Optimises a series of transformations parsed from a single - transform="" attribute. - - The transformation list is modified in-place. - """ - # FIXME: reordering these would optimize even more cases: - # first: Fold consecutive runs of the same transformation - # extra: Attempt to cast between types to create sameness: - # "matrix(0 1 -1 0 0 0) rotate(180) scale(-1)" all - # are rotations (90, 180, 180) -- thus "rotate(90)" - # second: Simplify transforms where numbers are optional. - # third: Attempt to simplify any single remaining matrix() - # - # if there's only one transformation and it's a matrix, - # try to make it a shorter non-matrix transformation - # NOTE: as matrix(a b c d e f) in SVG means the matrix: - # |¯ a c e ¯| make constants |¯ A1 A2 A3 ¯| - # | b d f | translating them | B1 B2 B3 | - # |_ 0 0 1 _| to more readable |_ 0 0 1 _| - if len(transform) == 1 and transform[0][0] == 'matrix': - matrix = A1, B1, A2, B2, A3, B3 = transform[0][1] - # |¯ 1 0 0 ¯| - # | 0 1 0 | Identity matrix (no transformation) - # |_ 0 0 1 _| - if matrix == [1, 0, 0, 1, 0, 0]: - del transform[0] - # |¯ 1 0 X ¯| - # | 0 1 Y | Translation by (X, Y). - # |_ 0 0 1 _| - elif (A1 == 1 and A2 == 0 - and B1 == 0 and B2 == 1): - transform[0] = ('translate', [A3, B3]) - # |¯ X 0 0 ¯| - # | 0 Y 0 | Scaling by (X, Y). - # |_ 0 0 1 _| - elif ( A2 == 0 and A3 == 0 - and B1 == 0 and B3 == 0): - transform[0] = ('scale', [A1, B2]) - # |¯ cos(A) -sin(A) 0 ¯| Rotation by angle A, - # | sin(A) cos(A) 0 | clockwise, about the origin. - # |_ 0 0 1 _| A is in degrees, [-180...180]. - elif (A1 == B2 and -1 <= A1 <= 1 and A3 == 0 - and -B1 == A2 and -1 <= B1 <= 1 and B3 == 0 - # as cos² A + sin² A == 1 and as decimal trig is approximate: - # FIXME: the "epsilon" term here should really be some function - # of the precision of the (sin|cos)_A terms, not 1e-15: - and abs((B1 ** 2) + (A1 ** 2) - 1) < Decimal("1e-15")): - sin_A, cos_A = B1, A1 - # while asin(A) and acos(A) both only have an 180° range - # the sign of sin(A) and cos(A) varies across quadrants, - # letting us hone in on the angle the matrix represents: - # -- => < -90 | -+ => -90..0 | ++ => 0..90 | +- => >= 90 - # - # http://en.wikipedia.org/wiki/File:Sine_cosine_plot.svg - # shows asin has the correct angle the middle quadrants: - A = Decimal(str(math.degrees(math.asin(float(sin_A))))) - if cos_A < 0: # otherwise needs adjusting from the edges - if sin_A < 0: - A = -180 - A - else: - A = 180 - A - transform[0] = ('rotate', [A]) - - # Simplify transformations where numbers are optional. - for type, args in transform: - if type == 'translate': - # Only the X coordinate is required for translations. - # If the Y coordinate is unspecified, it's 0. - if len(args) == 2 and args[1] == 0: - del args[1] - elif type == 'rotate': - args[0] = optimizeAngle(args[0]) # angle - # Only the angle is required for rotations. - # If the coordinates are unspecified, it's the origin (0, 0). - if len(args) == 3 and args[1] == args[2] == 0: - del args[1:] - elif type == 'scale': - # Only the X scaling factor is required. - # If the Y factor is unspecified, it's the same as X. - if len(args) == 2 and args[0] == args[1]: - del args[1] - - # Attempt to coalesce runs of the same transformation. - # Translations followed immediately by other translations, - # rotations followed immediately by other rotations, - # scaling followed immediately by other scaling, - # are safe to add. - # Identity skewX/skewY are safe to remove, but how do they accrete? - # |¯ 1 0 0 ¯| - # | tan(A) 1 0 | skews X coordinates by angle A - # |_ 0 0 1 _| - # - # |¯ 1 tan(A) 0 ¯| - # | 0 1 0 | skews Y coordinates by angle A - # |_ 0 0 1 _| - # - # FIXME: A matrix followed immediately by another matrix - # would be safe to multiply together, too. - i = 1 - while i < len(transform): - currType, currArgs = transform[i] - prevType, prevArgs = transform[i - 1] - if currType == prevType == 'translate': - prevArgs[0] += currArgs[0] # x - # for y, only add if the second translation has an explicit y - if len(currArgs) == 2: - if len(prevArgs) == 2: - prevArgs[1] += currArgs[1] # y - elif len(prevArgs) == 1: - prevArgs.append(currArgs[1]) # y - del transform[i] - if prevArgs[0] == prevArgs[1] == 0: - # Identity translation! - i -= 1 - del transform[i] - elif (currType == prevType == 'rotate' - and len(prevArgs) == len(currArgs) == 1): - # Only coalesce if both rotations are from the origin. - prevArgs[0] = optimizeAngle(prevArgs[0] + currArgs[0]) - del transform[i] - elif currType == prevType == 'scale': - prevArgs[0] *= currArgs[0] # x - # handle an implicit y - if len(prevArgs) == 2 and len(currArgs) == 2: - # y1 * y2 - prevArgs[1] *= currArgs[1] - elif len(prevArgs) == 1 and len(currArgs) == 2: - # create y2 = uniformscalefactor1 * y2 - prevArgs.append(prevArgs[0] * currArgs[1]) - elif len(prevArgs) == 2 and len(currArgs) == 1: - # y1 * uniformscalefactor2 - prevArgs[1] *= currArgs[0] - del transform[i] - if prevArgs[0] == prevArgs[1] == 1: - # Identity scale! - i -= 1 - del transform[i] - else: - i += 1 - - # Some fixups are needed for single-element transformation lists, since - # the loop above was to coalesce elements with their predecessors in the - # list, and thus it required 2 elements. - i = 0 - while i < len(transform): - currType, currArgs = transform[i] - if ((currType == 'skewX' or currType == 'skewY') - and len(currArgs) == 1 and currArgs[0] == 0): - # Identity skew! - del transform[i] - elif ((currType == 'rotate') - and len(currArgs) == 1 and currArgs[0] == 0): - # Identity rotation! - del transform[i] - else: - i += 1 - -def optimizeTransforms(element, options) : - """ - Attempts to optimise transform specifications on the given node and its children. - - Returns the number of bytes saved after performing these reductions. - """ - num = 0 - - for transformAttr in ['transform', 'patternTransform', 'gradientTransform']: - val = element.getAttribute(transformAttr) - if val != '': - transform = svg_transform_parser.parse(val) - - optimizeTransform(transform) - - newVal = serializeTransform(transform) - - if len(newVal) < len(val): - if len(newVal): - element.setAttribute(transformAttr, newVal) - else: - element.removeAttribute(transformAttr) - num += len(val) - len(newVal) - - for child in element.childNodes: - if child.nodeType == 1: - num += optimizeTransforms(child, options) - - return num - -def removeComments(element) : - """ - Removes comments from the element and its children. - """ - global numCommentBytes - - if isinstance(element, xml.dom.minidom.Document): - # must process the document object separately, because its - # documentElement's nodes have None as their parentNode - # iterate in reverse order to prevent mess-ups with renumbering - for index in xrange(len(element.childNodes) - 1, -1, -1): - subelement = element.childNodes[index] - if isinstance(subelement, xml.dom.minidom.Comment): - numCommentBytes += len(subelement.data) - element.removeChild(subelement) - else: - removeComments(subelement) - elif isinstance(element, xml.dom.minidom.Comment): - numCommentBytes += len(element.data) - element.parentNode.removeChild(element) - else: - # iterate in reverse order to prevent mess-ups with renumbering - for index in xrange(len(element.childNodes) - 1, -1, -1): - subelement = element.childNodes[index] - removeComments(subelement) - -def embedRasters(element, options) : - import base64 - import urllib - """ - Converts raster references to inline images. - NOTE: there are size limits to base64-encoding handling in browsers - """ - global numRastersEmbedded - - href = element.getAttributeNS(NS['XLINK'],'href') - - # if xlink:href is set, then grab the id - if href != '' and len(href) > 1: - # find if href value has filename ext - ext = os.path.splitext(os.path.basename(href))[1].lower()[1:] - - # look for 'png', 'jpg', and 'gif' extensions - if ext == 'png' or ext == 'jpg' or ext == 'gif': - - # file:// URLs denote files on the local system too - if href[:7] == 'file://': - href = href[7:] - # does the file exist? - if os.path.isfile(href): - # if this is not an absolute path, set path relative - # to script file based on input arg - infilename = '.' - if options.infilename: infilename = options.infilename - href = os.path.join(os.path.dirname(infilename), href) - - rasterdata = '' - # test if file exists locally - if os.path.isfile(href): - # open raster file as raw binary - raster = open( href, "rb") - rasterdata = raster.read() - elif href[:7] == 'http://': - webFile = urllib.urlopen( href ) - rasterdata = webFile.read() - webFile.close() - - # ... should we remove all images which don't resolve? - if rasterdata != '' : - # base64-encode raster - b64eRaster = base64.b64encode( rasterdata ) - - # set href attribute to base64-encoded equivalent - if b64eRaster != '': - # PNG and GIF both have MIME Type 'image/[ext]', but - # JPEG has MIME Type 'image/jpeg' - if ext == 'jpg': - ext = 'jpeg' - - element.setAttributeNS(NS['XLINK'], 'href', 'data:image/' + ext + ';base64,' + b64eRaster) - numRastersEmbedded += 1 - del b64eRaster - -def properlySizeDoc(docElement, options): - # get doc width and height - w = SVGLength(docElement.getAttribute('width')) - h = SVGLength(docElement.getAttribute('height')) - - # if width/height are not unitless or px then it is not ok to rewrite them into a viewBox. - # well, it may be OK for Web browsers and vector editors, but not for librsvg. - if options.renderer_workaround: - if ((w.units != Unit.NONE and w.units != Unit.PX) or - (h.units != Unit.NONE and h.units != Unit.PX)): - return - - # else we have a statically sized image and we should try to remedy that - - # parse viewBox attribute - vbSep = re.split("\\s*\\,?\\s*", docElement.getAttribute('viewBox'), 3) - # if we have a valid viewBox we need to check it - vbWidth,vbHeight = 0,0 - if len(vbSep) == 4: - try: - # if x or y are specified and non-zero then it is not ok to overwrite it - vbX = float(vbSep[0]) - vbY = float(vbSep[1]) - if vbX != 0 or vbY != 0: - return - - # if width or height are not equal to doc width/height then it is not ok to overwrite it - vbWidth = float(vbSep[2]) - vbHeight = float(vbSep[3]) - if vbWidth != w.value or vbHeight != h.value: - return - # if the viewBox did not parse properly it is invalid and ok to overwrite it - except ValueError: - pass - - # at this point it's safe to set the viewBox and remove width/height - docElement.setAttribute('viewBox', '0 0 %s %s' % (w.value, h.value)) - docElement.removeAttribute('width') - docElement.removeAttribute('height') - -def remapNamespacePrefix(node, oldprefix, newprefix): - if node == None or node.nodeType != 1: return - - if node.prefix == oldprefix: - localName = node.localName - namespace = node.namespaceURI - doc = node.ownerDocument - parent = node.parentNode - - # create a replacement node - newNode = None - if newprefix != '': - newNode = doc.createElementNS(namespace, newprefix+":"+localName) - else: - newNode = doc.createElement(localName); - - # add all the attributes - attrList = node.attributes - for i in xrange(attrList.length): - attr = attrList.item(i) - newNode.setAttributeNS( attr.namespaceURI, attr.localName, attr.nodeValue) - - # clone and add all the child nodes - for child in node.childNodes: - newNode.appendChild(child.cloneNode(True)) - - # replace old node with new node - parent.replaceChild( newNode, node ) - # set the node to the new node in the remapped namespace prefix - node = newNode - - # now do all child nodes - for child in node.childNodes : - remapNamespacePrefix(child, oldprefix, newprefix) - -def makeWellFormed(str): - xml_ents = { '<':'<', '>':'>', '&':'&', "'":''', '"':'"'} - -# starr = [] -# for c in str: -# if c in xml_ents: -# starr.append(xml_ents[c]) -# else: -# starr.append(c) - - # this list comprehension is short-form for the above for-loop: - return ''.join([xml_ents[c] if c in xml_ents else c for c in str]) - -# hand-rolled serialization function that has the following benefits: -# - pretty printing -# - somewhat judicious use of whitespace -# - ensure id attributes are first -def serializeXML(element, options, ind = 0, preserveWhitespace = False): - outParts = [] - - indent = ind - I='' - if options.indent_type == 'tab': I='\t' - elif options.indent_type == 'space': I=' ' - - outParts.extend([(I * ind), '<', element.nodeName]) - - # always serialize the id or xml:id attributes first - if element.getAttribute('id') != '': - id = element.getAttribute('id') - quot = '"' - if id.find('"') != -1: - quot = "'" - outParts.extend([' id=', quot, id, quot]) - if element.getAttribute('xml:id') != '': - id = element.getAttribute('xml:id') - quot = '"' - if id.find('"') != -1: - quot = "'" - outParts.extend([' xml:id=', quot, id, quot]) - - # now serialize the other attributes - attrList = element.attributes - for num in xrange(attrList.length) : - attr = attrList.item(num) - if attr.nodeName == 'id' or attr.nodeName == 'xml:id': continue - # if the attribute value contains a double-quote, use single-quotes - quot = '"' - if attr.nodeValue.find('"') != -1: - quot = "'" - - attrValue = makeWellFormed( attr.nodeValue ) - - outParts.append(' ') - # preserve xmlns: if it is a namespace prefix declaration - if attr.prefix != None: - outParts.extend([attr.prefix, ':']) - elif attr.namespaceURI != None: - if attr.namespaceURI == 'http://www.w3.org/2000/xmlns/' and attr.nodeName.find('xmlns') == -1: - outParts.append('xmlns:') - elif attr.namespaceURI == 'http://www.w3.org/1999/xlink': - outParts.append('xlink:') - outParts.extend([attr.localName, '=', quot, attrValue, quot]) - - if attr.nodeName == 'xml:space': - if attrValue == 'preserve': - preserveWhitespace = True - elif attrValue == 'default': - preserveWhitespace = False - - # if no children, self-close - children = element.childNodes - if children.length > 0: - outParts.append('>') - - onNewLine = False - for child in element.childNodes: - # element node - if child.nodeType == 1: - if preserveWhitespace: - outParts.append(serializeXML(child, options, 0, preserveWhitespace)) - else: - outParts.extend(['\n', serializeXML(child, options, indent + 1, preserveWhitespace)]) - onNewLine = True - # text node - elif child.nodeType == 3: - # trim it only in the case of not being a child of an element - # where whitespace might be important - if preserveWhitespace: - outParts.append(makeWellFormed(child.nodeValue)) - else: - outParts.append(makeWellFormed(child.nodeValue.strip())) - # CDATA node - elif child.nodeType == 4: - outParts.extend(['<![CDATA[', child.nodeValue, ']]>']) - # Comment node - elif child.nodeType == 8: - outParts.extend(['<!--', child.nodeValue, '-->']) - # TODO: entities, processing instructions, what else? - else: # ignore the rest - pass - - if onNewLine: outParts.append(I * ind) - outParts.extend(['</', element.nodeName, '>']) - if indent > 0: outParts.append('\n') - else: - outParts.append('/>') - if indent > 0: outParts.append('\n') - - return "".join(outParts) - -# this is the main method -# input is a string representation of the input XML -# returns a string representation of the output XML -def scourString(in_string, options=None): - if options is None: - options = _options_parser.get_default_values() - getcontext().prec = options.digits - global numAttrsRemoved - global numStylePropsFixed - global numElemsRemoved - global numBytesSavedInColors - global numCommentsRemoved - global numBytesSavedInIDs - global numBytesSavedInLengths - global numBytesSavedInTransforms - doc = xml.dom.minidom.parseString(in_string) - - # for whatever reason this does not always remove all inkscape/sodipodi attributes/elements - # on the first pass, so we do it multiple times - # does it have to do with removal of children affecting the childlist? - if options.keep_editor_data == False: - while removeNamespacedElements( doc.documentElement, unwanted_ns ) > 0 : - pass - while removeNamespacedAttributes( doc.documentElement, unwanted_ns ) > 0 : - pass - - # remove the xmlns: declarations now - xmlnsDeclsToRemove = [] - attrList = doc.documentElement.attributes - for num in xrange(attrList.length) : - if attrList.item(num).nodeValue in unwanted_ns : - xmlnsDeclsToRemove.append(attrList.item(num).nodeName) - - for attr in xmlnsDeclsToRemove : - doc.documentElement.removeAttribute(attr) - numAttrsRemoved += 1 - - # ensure namespace for SVG is declared - # TODO: what if the default namespace is something else (i.e. some valid namespace)? - if doc.documentElement.getAttribute('xmlns') != 'http://www.w3.org/2000/svg': - doc.documentElement.setAttribute('xmlns', 'http://www.w3.org/2000/svg') - # TODO: throw error or warning? - - # check for redundant SVG namespace declaration - attrList = doc.documentElement.attributes - xmlnsDeclsToRemove = [] - redundantPrefixes = [] - for i in xrange(attrList.length): - attr = attrList.item(i) - name = attr.nodeName - val = attr.nodeValue - if name[0:6] == 'xmlns:' and val == 'http://www.w3.org/2000/svg': - redundantPrefixes.append(name[6:]) - xmlnsDeclsToRemove.append(name) - - for attrName in xmlnsDeclsToRemove: - doc.documentElement.removeAttribute(attrName) - - for prefix in redundantPrefixes: - remapNamespacePrefix(doc.documentElement, prefix, '') - - if options.strip_comments: - numCommentsRemoved = removeComments(doc) - - # repair style (remove unnecessary style properties and change them into XML attributes) - numStylePropsFixed = repairStyle(doc.documentElement, options) - - # convert colors to #RRGGBB format - if options.simple_colors: - numBytesSavedInColors = convertColors(doc.documentElement) - - # remove <metadata> if the user wants to - if options.remove_metadata: - removeMetadataElements(doc) - - # flattend defs elements into just one defs element - flattenDefs(doc) - - # remove unreferenced gradients/patterns outside of defs - # and most unreferenced elements inside of defs - while removeUnreferencedElements(doc) > 0: - pass - - # remove empty defs, metadata, g - # NOTE: these elements will be removed if they just have whitespace-only text nodes - for tag in ['defs', 'metadata', 'g'] : - for elem in doc.documentElement.getElementsByTagName(tag) : - removeElem = not elem.hasChildNodes() - if removeElem == False : - for child in elem.childNodes : - if child.nodeType in [1, 4, 8]: - break - elif child.nodeType == 3 and not child.nodeValue.isspace(): - break - else: - removeElem = True - if removeElem : - elem.parentNode.removeChild(elem) - numElemsRemoved += 1 - - if options.strip_ids: - bContinueLooping = True - while bContinueLooping: - identifiedElements = unprotected_ids(doc, options) - referencedIDs = findReferencedElements(doc.documentElement) - bContinueLooping = (removeUnreferencedIDs(referencedIDs, identifiedElements) > 0) - - while removeDuplicateGradientStops(doc) > 0: - pass - - # remove gradients that are only referenced by one other gradient - while collapseSinglyReferencedGradients(doc) > 0: - pass - - # remove duplicate gradients - while removeDuplicateGradients(doc) > 0: - pass - - # create <g> elements if there are runs of elements with the same attributes. - # this MUST be before moveCommonAttributesToParentGroup. - if options.group_create: - createGroupsForCommonAttributes(doc.documentElement) - - # move common attributes to parent group - # NOTE: the if the <svg> element's immediate children - # all have the same value for an attribute, it must not - # get moved to the <svg> element. The <svg> element - # doesn't accept fill=, stroke= etc.! - referencedIds = findReferencedElements(doc.documentElement) - for child in doc.documentElement.childNodes: - numAttrsRemoved += moveCommonAttributesToParentGroup(child, referencedIds) - - # remove unused attributes from parent - numAttrsRemoved += removeUnusedAttributesOnParent(doc.documentElement) - - # Collapse groups LAST, because we've created groups. If done before - # moveAttributesToParentGroup, empty <g>'s may remain. - if options.group_collapse: - while removeNestedGroups(doc.documentElement) > 0: - pass - - # remove unnecessary closing point of polygons and scour points - for polygon in doc.documentElement.getElementsByTagName('polygon') : - cleanPolygon(polygon, options) - - # scour points of polyline - for polyline in doc.documentElement.getElementsByTagName('polyline') : - cleanPolyline(polyline, options) - - # clean path data - for elem in doc.documentElement.getElementsByTagName('path') : - if elem.getAttribute('d') == '': - elem.parentNode.removeChild(elem) - else: - cleanPath(elem, options) - - # shorten ID names as much as possible - if options.shorten_ids: - numBytesSavedInIDs += shortenIDs(doc, unprotected_ids(doc, options)) - - # scour lengths (including coordinates) - for type in ['svg', 'image', 'rect', 'circle', 'ellipse', 'line', 'linearGradient', 'radialGradient', 'stop', 'filter']: - for elem in doc.getElementsByTagName(type): - for attr in ['x', 'y', 'width', 'height', 'cx', 'cy', 'r', 'rx', 'ry', - 'x1', 'y1', 'x2', 'y2', 'fx', 'fy', 'offset']: - if elem.getAttribute(attr) != '': - elem.setAttribute(attr, scourLength(elem.getAttribute(attr))) - - # more length scouring in this function - numBytesSavedInLengths = reducePrecision(doc.documentElement) - - # remove default values of attributes - numAttrsRemoved += removeDefaultAttributeValues(doc.documentElement, options) - - # reduce the length of transformation attributes - numBytesSavedInTransforms = optimizeTransforms(doc.documentElement, options) - - # convert rasters references to base64-encoded strings - if options.embed_rasters: - for elem in doc.documentElement.getElementsByTagName('image') : - embedRasters(elem, options) - - # properly size the SVG document (ideally width/height should be 100% with a viewBox) - if options.enable_viewboxing: - properlySizeDoc(doc.documentElement, options) - - # output the document as a pretty string with a single space for indent - # NOTE: removed pretty printing because of this problem: - # http://ronrothman.com/public/leftbraned/xml-dom-minidom-toprettyxml-and-silly-whitespace/ - # rolled our own serialize function here to save on space, put id first, customize indentation, etc -# out_string = doc.documentElement.toprettyxml(' ') - out_string = serializeXML(doc.documentElement, options) + '\n' - - # now strip out empty lines - lines = [] - # Get rid of empty lines - for line in out_string.splitlines(True): - if line.strip(): - lines.append(line) - - # return the string with its XML prolog and surrounding comments - if options.strip_xml_prolog == False: - total_output = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' - else: - total_output = "" - - for child in doc.childNodes: - if child.nodeType == 1: - total_output += "".join(lines) - else: # doctypes, entities, comments - total_output += child.toxml() + '\n' - - return total_output - -# used mostly by unit tests -# input is a filename -# returns the minidom doc representation of the SVG -def scourXmlFile(filename, options=None): - in_string = open(filename).read() - out_string = scourString(in_string, options) - return xml.dom.minidom.parseString(out_string.encode('utf-8')) - -# GZ: Seems most other commandline tools don't do this, is it really wanted? -class HeaderedFormatter(optparse.IndentedHelpFormatter): - """ - Show application name, version number, and copyright statement - above usage information. - """ - def format_usage(self, usage): - return "%s %s\n%s\n%s" % (APP, VER, COPYRIGHT, - optparse.IndentedHelpFormatter.format_usage(self, usage)) - -# GZ: would prefer this to be in a function or class scope, but tests etc need -# access to the defaults anyway -_options_parser = optparse.OptionParser( - usage="%prog [-i input.svg] [-o output.svg] [OPTIONS]", - description=("If the input/output files are specified with a svgz" - " extension, then compressed SVG is assumed. If the input file is not" - " specified, stdin is used. If the output file is not specified, " - " stdout is used."), - formatter=HeaderedFormatter(max_help_position=30), - version=VER) - -_options_parser.add_option("--disable-simplify-colors", - action="store_false", dest="simple_colors", default=True, - help="won't convert all colors to #RRGGBB format") -_options_parser.add_option("--disable-style-to-xml", - action="store_false", dest="style_to_xml", default=True, - help="won't convert styles into XML attributes") -_options_parser.add_option("--disable-group-collapsing", - action="store_false", dest="group_collapse", default=True, - help="won't collapse <g> elements") -_options_parser.add_option("--create-groups", - action="store_true", dest="group_create", default=False, - help="create <g> elements for runs of elements with identical attributes") -_options_parser.add_option("--enable-id-stripping", - action="store_true", dest="strip_ids", default=False, - help="remove all un-referenced ID attributes") -_options_parser.add_option("--enable-comment-stripping", - action="store_true", dest="strip_comments", default=False, - help="remove all <!-- --> comments") -_options_parser.add_option("--shorten-ids", - action="store_true", dest="shorten_ids", default=False, - help="shorten all ID attributes to the least number of letters possible") -_options_parser.add_option("--disable-embed-rasters", - action="store_false", dest="embed_rasters", default=True, - help="won't embed rasters as base64-encoded data") -_options_parser.add_option("--keep-editor-data", - action="store_true", dest="keep_editor_data", default=False, - help="won't remove Inkscape, Sodipodi or Adobe Illustrator elements and attributes") -_options_parser.add_option("--remove-metadata", - action="store_true", dest="remove_metadata", default=False, - help="remove <metadata> elements (which may contain license metadata etc.)") -_options_parser.add_option("--renderer-workaround", - action="store_true", dest="renderer_workaround", default=True, - help="work around various renderer bugs (currently only librsvg) (default)") -_options_parser.add_option("--no-renderer-workaround", - action="store_false", dest="renderer_workaround", default=True, - help="do not work around various renderer bugs (currently only librsvg)") -_options_parser.add_option("--strip-xml-prolog", - action="store_true", dest="strip_xml_prolog", default=False, - help="won't output the <?xml ?> prolog") -_options_parser.add_option("--enable-viewboxing", - action="store_true", dest="enable_viewboxing", default=False, - help="changes document width/height to 100%/100% and creates viewbox coordinates") - -# GZ: this is confusing, most people will be thinking in terms of -# decimal places, which is not what decimal precision is doing -_options_parser.add_option("-p", "--set-precision", - action="store", type=int, dest="digits", default=5, - help="set number of significant digits (default: %default)") -_options_parser.add_option("-i", - action="store", dest="infilename", help=optparse.SUPPRESS_HELP) -_options_parser.add_option("-o", - action="store", dest="outfilename", help=optparse.SUPPRESS_HELP) -_options_parser.add_option("-q", "--quiet", - action="store_true", dest="quiet", default=False, - help="suppress non-error output") -_options_parser.add_option("--indent", - action="store", type="string", dest="indent_type", default="space", - help="indentation of the output: none, space, tab (default: %default)") -_options_parser.add_option("--protect-ids-noninkscape", - action="store_true", dest="protect_ids_noninkscape", default=False, - help="Don't change IDs not ending with a digit") -_options_parser.add_option("--protect-ids-list", - action="store", type="string", dest="protect_ids_list", default=None, - help="Don't change IDs given in a comma-separated list") -_options_parser.add_option("--protect-ids-prefix", - action="store", type="string", dest="protect_ids_prefix", default=None, - help="Don't change IDs starting with the given prefix") - -def maybe_gziped_file(filename, mode="r"): - if os.path.splitext(filename)[1].lower() in (".svgz", ".gz"): - import gzip - return gzip.GzipFile(filename, mode) - return file(filename, mode) - -def parse_args(args=None): - options, rargs = _options_parser.parse_args(args) - - if rargs: - _options_parser.error("Additional arguments not handled: %r, see --help" % rargs) - if options.digits < 0: - _options_parser.error("Can't have negative significant digits, see --help") - if not options.indent_type in ["tab", "space", "none"]: - _options_parser.error("Invalid value for --indent, see --help") - if options.infilename and options.outfilename and options.infilename == options.outfilename: - _options_parser.error("Input filename is the same as output filename") - - if options.infilename: - infile = maybe_gziped_file(options.infilename) - # GZ: could catch a raised IOError here and report - else: - # GZ: could sniff for gzip compression here - infile = sys.stdin - if options.outfilename: - outfile = maybe_gziped_file(options.outfilename, "wb") - else: - outfile = sys.stdout - - return options, [infile, outfile] - -def getReport(): - return ' Number of elements removed: ' + str(numElemsRemoved) + os.linesep + \ - ' Number of attributes removed: ' + str(numAttrsRemoved) + os.linesep + \ - ' Number of unreferenced id attributes removed: ' + str(numIDsRemoved) + os.linesep + \ - ' Number of style properties fixed: ' + str(numStylePropsFixed) + os.linesep + \ - ' Number of raster images embedded inline: ' + str(numRastersEmbedded) + os.linesep + \ - ' Number of path segments reduced/removed: ' + str(numPathSegmentsReduced) + os.linesep + \ - ' Number of bytes saved in path data: ' + str(numBytesSavedInPathData) + os.linesep + \ - ' Number of bytes saved in colors: ' + str(numBytesSavedInColors) + os.linesep + \ - ' Number of points removed from polygons: ' + str(numPointsRemovedFromPolygon) + os.linesep + \ - ' Number of bytes saved in comments: ' + str(numCommentBytes) + os.linesep + \ - ' Number of bytes saved in id attributes: ' + str(numBytesSavedInIDs) + os.linesep + \ - ' Number of bytes saved in lengths: ' + str(numBytesSavedInLengths) + os.linesep + \ - ' Number of bytes saved in transformations: ' + str(numBytesSavedInTransforms) - -if __name__ == '__main__': - if sys.platform == "win32": - from time import clock as get_tick - else: - # GZ: is this different from time.time() in any way? - def get_tick(): - return os.times()[0] - - start = get_tick() - - options, (input, output) = parse_args() - - if not options.quiet: - print >>sys.stderr, "%s %s\n%s" % (APP, VER, COPYRIGHT) - - # do the work - in_string = input.read() - out_string = scourString(in_string, options).encode("UTF-8") - output.write(out_string) - - # Close input and output files - input.close() - output.close() - - end = get_tick() - - # GZ: not using globals would be good too - if not options.quiet: - print >>sys.stderr, ' File:', input.name, \ - os.linesep + ' Time taken:', str(end-start) + 's' + os.linesep, \ - getReport() - - oldsize = len(in_string) - newsize = len(out_string) - sizediff = (newsize / oldsize) * 100 - print >>sys.stderr, ' Original file size:', oldsize, 'bytes;', \ - 'new file size:', newsize, 'bytes (' + str(sizediff)[:5] + '%)' diff --git a/share/extensions/scour/svg_regex.py b/share/extensions/scour/svg_regex.py deleted file mode 100644 index 6321bff0e..000000000 --- a/share/extensions/scour/svg_regex.py +++ /dev/null @@ -1,286 +0,0 @@ -#!/usr/bin/env python -# This software is OSI Certified Open Source Software. -# OSI Certified is a certification mark of the Open Source Initiative. -# -# Copyright (c) 2006, Enthought, Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# * Neither the name of Enthought, Inc. nor the names of its contributors may -# be used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -""" Small hand-written recursive descent parser for SVG <path> data. - - -In [1]: from svg_regex import svg_parser - -In [3]: svg_parser.parse('M 10,20 30,40V50 60 70') -Out[3]: [('M', [(10.0, 20.0), (30.0, 40.0)]), ('V', [50.0, 60.0, 70.0])] - -In [4]: svg_parser.parse('M 0.6051.5') # An edge case -Out[4]: [('M', [(0.60509999999999997, 0.5)])] - -In [5]: svg_parser.parse('M 100-200') # Another edge case -Out[5]: [('M', [(100.0, -200.0)])] -""" - -import re -from decimal import * - - -# Sentinel. -class _EOF(object): - def __repr__(self): - return 'EOF' -EOF = _EOF() - -lexicon = [ - ('float', r'[-+]?(?:(?:[0-9]*\.[0-9]+)|(?:[0-9]+\.?))(?:[Ee][-+]?[0-9]+)?'), - ('int', r'[-+]?[0-9]+'), - ('command', r'[AaCcHhLlMmQqSsTtVvZz]'), -] - - -class Lexer(object): - """ Break SVG path data into tokens. - - The SVG spec requires that tokens are greedy. This lexer relies on Python's - regexes defaulting to greediness. - - This style of implementation was inspired by this article: - - http://www.gooli.org/blog/a-simple-lexer-in-python/ - """ - def __init__(self, lexicon): - self.lexicon = lexicon - parts = [] - for name, regex in lexicon: - parts.append('(?P<%s>%s)' % (name, regex)) - self.regex_string = '|'.join(parts) - self.regex = re.compile(self.regex_string) - - def lex(self, text): - """ Yield (token_type, str_data) tokens. - - The last token will be (EOF, None) where EOF is the singleton object - defined in this module. - """ - for match in self.regex.finditer(text): - for name, _ in self.lexicon: - m = match.group(name) - if m is not None: - yield (name, m) - break - yield (EOF, None) - -svg_lexer = Lexer(lexicon) - - -class SVGPathParser(object): - """ Parse SVG <path> data into a list of commands. - - Each distinct command will take the form of a tuple (command, data). The - `command` is just the character string that starts the command group in the - <path> data, so 'M' for absolute moveto, 'm' for relative moveto, 'Z' for - closepath, etc. The kind of data it carries with it depends on the command. - For 'Z' (closepath), it's just None. The others are lists of individual - argument groups. Multiple elements in these lists usually mean to repeat the - command. The notable exception is 'M' (moveto) where only the first element - is truly a moveto. The remainder are implicit linetos. - - See the SVG documentation for the interpretation of the individual elements - for each command. - - The main method is `parse(text)`. It can only consume actual strings, not - filelike objects or iterators. - """ - - def __init__(self, lexer=svg_lexer): - self.lexer = lexer - - self.command_dispatch = { - 'Z': self.rule_closepath, - 'z': self.rule_closepath, - 'M': self.rule_moveto_or_lineto, - 'm': self.rule_moveto_or_lineto, - 'L': self.rule_moveto_or_lineto, - 'l': self.rule_moveto_or_lineto, - 'H': self.rule_orthogonal_lineto, - 'h': self.rule_orthogonal_lineto, - 'V': self.rule_orthogonal_lineto, - 'v': self.rule_orthogonal_lineto, - 'C': self.rule_curveto3, - 'c': self.rule_curveto3, - 'S': self.rule_curveto2, - 's': self.rule_curveto2, - 'Q': self.rule_curveto2, - 'q': self.rule_curveto2, - 'T': self.rule_curveto1, - 't': self.rule_curveto1, - 'A': self.rule_elliptical_arc, - 'a': self.rule_elliptical_arc, - } - -# self.number_tokens = set(['int', 'float']) - self.number_tokens = list(['int', 'float']) - - def parse(self, text): - """ Parse a string of SVG <path> data. - """ - next = self.lexer.lex(text).next - token = next() - return self.rule_svg_path(next, token) - - def rule_svg_path(self, next, token): - commands = [] - while token[0] is not EOF: - if token[0] != 'command': - raise SyntaxError("expecting a command; got %r" % (token,)) - rule = self.command_dispatch[token[1]] - command_group, token = rule(next, token) - commands.append(command_group) - return commands - - def rule_closepath(self, next, token): - command = token[1] - token = next() - return (command, []), token - - def rule_moveto_or_lineto(self, next, token): - command = token[1] - token = next() - coordinates = [] - while token[0] in self.number_tokens: - pair, token = self.rule_coordinate_pair(next, token) - coordinates.extend(pair) - return (command, coordinates), token - - def rule_orthogonal_lineto(self, next, token): - command = token[1] - token = next() - coordinates = [] - while token[0] in self.number_tokens: - coord, token = self.rule_coordinate(next, token) - coordinates.append(coord) - return (command, coordinates), token - - def rule_curveto3(self, next, token): - command = token[1] - token = next() - coordinates = [] - while token[0] in self.number_tokens: - pair1, token = self.rule_coordinate_pair(next, token) - pair2, token = self.rule_coordinate_pair(next, token) - pair3, token = self.rule_coordinate_pair(next, token) - coordinates.extend(pair1) - coordinates.extend(pair2) - coordinates.extend(pair3) - return (command, coordinates), token - - def rule_curveto2(self, next, token): - command = token[1] - token = next() - coordinates = [] - while token[0] in self.number_tokens: - pair1, token = self.rule_coordinate_pair(next, token) - pair2, token = self.rule_coordinate_pair(next, token) - coordinates.extend(pair1) - coordinates.extend(pair2) - return (command, coordinates), token - - def rule_curveto1(self, next, token): - command = token[1] - token = next() - coordinates = [] - while token[0] in self.number_tokens: - pair1, token = self.rule_coordinate_pair(next, token) - coordinates.extend(pair1) - return (command, coordinates), token - - def rule_elliptical_arc(self, next, token): - command = token[1] - token = next() - arguments = [] - while token[0] in self.number_tokens: - rx = Decimal(token[1]) * 1 - if rx < Decimal("0.0"): - raise SyntaxError("expecting a nonnegative number; got %r" % (token,)) - - token = next() - if token[0] not in self.number_tokens: - raise SyntaxError("expecting a number; got %r" % (token,)) - ry = Decimal(token[1]) * 1 - if ry < Decimal("0.0"): - raise SyntaxError("expecting a nonnegative number; got %r" % (token,)) - - token = next() - if token[0] not in self.number_tokens: - raise SyntaxError("expecting a number; got %r" % (token,)) - axis_rotation = Decimal(token[1]) * 1 - - token = next() - if token[1] not in ('0', '1'): - raise SyntaxError("expecting a boolean flag; got %r" % (token,)) - large_arc_flag = Decimal(token[1]) * 1 - - token = next() - if token[1] not in ('0', '1'): - raise SyntaxError("expecting a boolean flag; got %r" % (token,)) - sweep_flag = Decimal(token[1]) * 1 - - token = next() - if token[0] not in self.number_tokens: - raise SyntaxError("expecting a number; got %r" % (token,)) - x = Decimal(token[1]) * 1 - - token = next() - if token[0] not in self.number_tokens: - raise SyntaxError("expecting a number; got %r" % (token,)) - y = Decimal(token[1]) * 1 - - token = next() - arguments.extend([rx, ry, axis_rotation, large_arc_flag, sweep_flag, x, y]) - - return (command, arguments), token - - def rule_coordinate(self, next, token): - if token[0] not in self.number_tokens: - raise SyntaxError("expecting a number; got %r" % (token,)) - x = getcontext().create_decimal(token[1]) - token = next() - return x, token - - - def rule_coordinate_pair(self, next, token): - # Inline these since this rule is so common. - if token[0] not in self.number_tokens: - raise SyntaxError("expecting a number; got %r" % (token,)) - x = getcontext().create_decimal(token[1]) - token = next() - if token[0] not in self.number_tokens: - raise SyntaxError("expecting a number; got %r" % (token,)) - y = getcontext().create_decimal(token[1]) - token = next() - return [x, y], token - - -svg_parser = SVGPathParser() diff --git a/share/extensions/scour/svg_transform.py b/share/extensions/scour/svg_transform.py deleted file mode 100644 index 860c1df5d..000000000 --- a/share/extensions/scour/svg_transform.py +++ /dev/null @@ -1,236 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# SVG transformation list parser -# -# Copyright 2010 Louis Simard -# -# This file is part of Scour, http://www.codedread.com/scour/ -# -# This library is free software; you can redistribute it and/or modify -# it either under the terms of the Apache License, Version 2.0, or, at -# your option, under the terms and conditions of the GNU General -# Public License, Version 2 or newer as published by the Free Software -# Foundation. You may obtain a copy of these Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" Small recursive descent parser for SVG transform="" data. - - -In [1]: from svg_transform import svg_transform_parser - -In [3]: svg_transform_parser.parse('translate(50, 50)') -Out[3]: [('translate', [50.0, 50.0])] - -In [4]: svg_transform_parser.parse('translate(50)') -Out[4]: [('translate', [50.0])] - -In [5]: svg_transform_parser.parse('rotate(36 50,50)') -Out[5]: [('rotate', [36.0, 50.0, 50.0])] - -In [6]: svg_transform_parser.parse('rotate(36)') -Out[6]: [('rotate', [36.0])] - -In [7]: svg_transform_parser.parse('skewX(20)') -Out[7]: [('skewX', [20.0])] - -In [8]: svg_transform_parser.parse('skewY(40)') -Out[8]: [('skewX', [20.0])] - -In [9]: svg_transform_parser.parse('scale(2 .5)') -Out[9]: [('scale', [2.0, 0.5])] - -In [10]: svg_transform_parser.parse('scale(.5)') -Out[10]: [('scale', [0.5])] - -In [11]: svg_transform_parser.parse('matrix(1 0 50 0 1 80)') -Out[11]: [('matrix', [1.0, 0.0, 50.0, 0.0, 1.0, 80.0])] - -Multiple transformations are supported: - -In [12]: svg_transform_parser.parse('translate(30 -30) rotate(36)') -Out[12]: [('translate', [30.0, -30.0]), ('rotate', [36.0])] -""" - -import re -from decimal import * - - -# Sentinel. -class _EOF(object): - def __repr__(self): - return 'EOF' -EOF = _EOF() - -lexicon = [ - ('float', r'[-+]?(?:(?:[0-9]*\.[0-9]+)|(?:[0-9]+\.?))(?:[Ee][-+]?[0-9]+)?'), - ('int', r'[-+]?[0-9]+'), - ('command', r'(?:matrix|translate|scale|rotate|skew[XY])'), - ('coordstart', r'\('), - ('coordend', r'\)'), -] - - -class Lexer(object): - """ Break SVG path data into tokens. - - The SVG spec requires that tokens are greedy. This lexer relies on Python's - regexes defaulting to greediness. - - This style of implementation was inspired by this article: - - http://www.gooli.org/blog/a-simple-lexer-in-python/ - """ - def __init__(self, lexicon): - self.lexicon = lexicon - parts = [] - for name, regex in lexicon: - parts.append('(?P<%s>%s)' % (name, regex)) - self.regex_string = '|'.join(parts) - self.regex = re.compile(self.regex_string) - - def lex(self, text): - """ Yield (token_type, str_data) tokens. - - The last token will be (EOF, None) where EOF is the singleton object - defined in this module. - """ - for match in self.regex.finditer(text): - for name, _ in self.lexicon: - m = match.group(name) - if m is not None: - yield (name, m) - break - yield (EOF, None) - -svg_lexer = Lexer(lexicon) - - -class SVGTransformationParser(object): - """ Parse SVG transform="" data into a list of commands. - - Each distinct command will take the form of a tuple (type, data). The - `type` is the character string that defines the type of transformation in the - transform data, so either of "translate", "rotate", "scale", "matrix", - "skewX" and "skewY". Data is always a list of numbers contained within the - transformation's parentheses. - - See the SVG documentation for the interpretation of the individual elements - for each transformation. - - The main method is `parse(text)`. It can only consume actual strings, not - filelike objects or iterators. - """ - - def __init__(self, lexer=svg_lexer): - self.lexer = lexer - - self.command_dispatch = { - 'translate': self.rule_1or2numbers, - 'scale': self.rule_1or2numbers, - 'skewX': self.rule_1number, - 'skewY': self.rule_1number, - 'rotate': self.rule_1or3numbers, - 'matrix': self.rule_6numbers, - } - -# self.number_tokens = set(['int', 'float']) - self.number_tokens = list(['int', 'float']) - - def parse(self, text): - """ Parse a string of SVG transform="" data. - """ - next = self.lexer.lex(text).next - commands = [] - token = next() - while token[0] is not EOF: - command, token = self.rule_svg_transform(next, token) - commands.append(command) - return commands - - def rule_svg_transform(self, next, token): - if token[0] != 'command': - raise SyntaxError("expecting a transformation type; got %r" % (token,)) - command = token[1] - rule = self.command_dispatch[command] - token = next() - if token[0] != 'coordstart': - raise SyntaxError("expecting '('; got %r" % (token,)) - numbers, token = rule(next, token) - if token[0] != 'coordend': - raise SyntaxError("expecting ')'; got %r" % (token,)) - token = next() - return (command, numbers), token - - def rule_1or2numbers(self, next, token): - numbers = [] - # 1st number is mandatory - token = next() - number, token = self.rule_number(next, token) - numbers.append(number) - # 2nd number is optional - number, token = self.rule_optional_number(next, token) - if number is not None: - numbers.append(number) - - return numbers, token - - def rule_1number(self, next, token): - # this number is mandatory - token = next() - number, token = self.rule_number(next, token) - numbers = [number] - return numbers, token - - def rule_1or3numbers(self, next, token): - numbers = [] - # 1st number is mandatory - token = next() - number, token = self.rule_number(next, token) - numbers.append(number) - # 2nd number is optional - number, token = self.rule_optional_number(next, token) - if number is not None: - # but, if the 2nd number is provided, the 3rd is mandatory. - # we can't have just 2. - numbers.append(number) - - number, token = self.rule_number(next, token) - numbers.append(number) - - return numbers, token - - def rule_6numbers(self, next, token): - numbers = [] - token = next() - # all numbers are mandatory - for i in xrange(6): - number, token = self.rule_number(next, token) - numbers.append(number) - return numbers, token - - def rule_number(self, next, token): - if token[0] not in self.number_tokens: - raise SyntaxError("expecting a number; got %r" % (token,)) - x = Decimal(token[1]) * 1 - token = next() - return x, token - - def rule_optional_number(self, next, token): - if token[0] not in self.number_tokens: - return None, token - else: - x = Decimal(token[1]) * 1 - token = next() - return x, token - - -svg_transform_parser = SVGTransformationParser() diff --git a/share/extensions/scour/yocto_css.py b/share/extensions/scour/yocto_css.py deleted file mode 100644 index c6bd0c37e..000000000 --- a/share/extensions/scour/yocto_css.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# yocto-css, an extremely bare minimum CSS parser -# -# Copyright 2009 Jeff Schiller -# -# This file is part of Scour, http://www.codedread.com/scour/ -# -# This library is free software; you can redistribute it and/or modify -# it either under the terms of the Apache License, Version 2.0, or, at -# your option, under the terms and conditions of the GNU General -# Public License, Version 2 or newer as published by the Free Software -# Foundation. You may obtain a copy of these Licenses at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# In order to resolve Bug 368716 (https://bugs.launchpad.net/scour/+bug/368716) -# scour needed a bare-minimum CSS parser in order to determine if some elements -# were still referenced by CSS properties. - -# I looked at css-py (a CSS parser built in Python), but that library -# is about 35k of Python and requires ply to be installed. I just need -# something very basic to suit scour's needs. - -# yocto-css takes a string of CSS and tries to spit out a list of rules -# A rule is an associative array (dictionary) with the following keys: -# - selector: contains the string of the selector (see CSS grammar) -# - properties: contains an associative array of CSS properties for this rule - -# TODO: need to build up some unit tests for yocto_css - -# stylesheet : [ CDO | CDC | S | statement ]*; -# statement : ruleset | at-rule; -# at-rule : ATKEYWORD S* any* [ block | ';' S* ]; -# block : '{' S* [ any | block | ATKEYWORD S* | ';' S* ]* '}' S*; -# ruleset : selector? '{' S* declaration? [ ';' S* declaration? ]* '}' S*; -# selector : any+; -# declaration : property S* ':' S* value; -# property : IDENT; -# value : [ any | block | ATKEYWORD S* ]+; -# any : [ IDENT | NUMBER | PERCENTAGE | DIMENSION | STRING -# | DELIM | URI | HASH | UNICODE-RANGE | INCLUDES -# | DASHMATCH | FUNCTION S* any* ')' -# | '(' S* any* ')' | '[' S* any* ']' ] S*; - -def parseCssString(str): - rules = [] - # first, split on } to get the rule chunks - chunks = str.split('}') - for chunk in chunks: - # second, split on { to get the selector and the list of properties - bits = chunk.split('{') - if len(bits) != 2: continue - rule = {} - rule['selector'] = bits[0].strip() - # third, split on ; to get the property declarations - bites = bits[1].strip().split(';') - if len(bites) < 1: continue - props = {} - for bite in bites: - # fourth, split on : to get the property name and value - nibbles = bite.strip().split(':') - if len(nibbles) != 2: continue - props[nibbles[0].strip()] = nibbles[1].strip() - rule['properties'] = props - rules.append(rule) - return rules diff --git a/share/extensions/seamless_pattern.py b/share/extensions/seamless_pattern.py index f48de954a..db8fd8c51 100644..100755 --- a/share/extensions/seamless_pattern.py +++ b/share/extensions/seamless_pattern.py @@ -1,159 +1,198 @@ -#!/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*5.5)/2.0) )
- namedview.set(inkex.addNS('cy', 'inkscape'), "0" )
- namedview.set(inkex.addNS('zoom', 'inkscape'), str(1.0 / (width/100.0)) )
-
-c = C()
-c.affect()
+#!/usr/bin/env python + +# Written by Jabiertxof +# V.06 + +import inkex, sys, re, 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): + saveout = sys.stdout + sys.stdout = sys.stderr + width = self.options.desktop_width + height = self.options.desktop_height + if height == 0 | width == 0: + return; + factor = float(width)/float(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)) + root.set("height", str(height)) + 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:pattern[@id="Checkerboard"]' + designZoneData = root.xpath(xpathStr, namespaces=inkex.NSS) + if designZoneData != []: + if factor <= 1: + designZoneData[0].set("patternTransform", "scale(" + str(10.0) + "," + str(factor * 10) + ")") + else: + designZoneData[0].set("patternTransform", "scale(" + str(10.0/factor) + "," + str(10.0) + ")") + + 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.0) + "," + str(height/100.0) + ")") + designZone[1].set("transform", "scale(" + str(width /100.0) + "," + str(height/100.0) + ")") + + xpathStr = '//svg:g[@id="designTop"]/child::*' + designZoneData = root.xpath(xpathStr, namespaces=inkex.NSS) + if designZoneData != []: + if factor <= 1: + designZoneData[0].set("transform", "scale(1," + str(factor) + ")") + designZoneData[1].set("transform", "scale(1," + str(factor) + ")") + designZoneData[2].set("transform", "scale(1," + str(factor) + ")") + else: + designZoneData[0].set("transform", "scale(" + str(1.0/factor) + ",1)") + designZoneData[1].set("transform", "scale(" + str(1.0/factor) + ",1)") + designZoneData[2].set("transform", "scale(" + str(1.0/factor) + ",1)") + + xpathStr = '//svg:g[@id="textPreview"]' + previewText = root.xpath(xpathStr, namespaces=inkex.NSS) + if previewText != []: + if factor <= 1: + previewText[0].set("transform", "translate(" + str(width * 2) + ",0) scale(" + str(width/100.0) + "," + str((height/100.0) * factor) + ")") + else: + previewText[0].set("transform", "translate(" + str(width * 2) + ",0) scale(" + str((width/100.0)/factor) + "," + str(height/100.0) + ")") + + xpathStr = '//svg:g[@id="infoGroup"]' + infoGroup = root.xpath(xpathStr, namespaces=inkex.NSS) + if infoGroup != []: + if factor <= 1: + infoGroup[0].set("transform", "scale(" + str(width/100.0) + "," + str((height/100.0) * factor) + ")") + else: + infoGroup[0].set("transform", "scale(" + str(width/1000.0) + "," + str((height/1000.0) * factor) + ")") + + 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*5.5)/2.0) ) + namedview.set(inkex.addNS('cy', 'inkscape'), "0" ) + namedview.set(inkex.addNS('zoom', 'inkscape'), str(1.0 / (width/100.00)) ) + sys.stdout = saveout + +c = C() +c.affect() diff --git a/share/extensions/seamless_pattern.svg b/share/extensions/seamless_pattern.svg index 7ed009394..5bff87af8 100644 --- a/share/extensions/seamless_pattern.svg +++ b/share/extensions/seamless_pattern.svg @@ -1,86 +1,102 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="100px" height="100px" viewBox="0 0 100 100" id="SVGRoot" version="1.1" inkscape:version="0.91pre2 r13624" sodipodi:docname="seamless_pattern.svg" inkscape:export-xdpi="96" inkscape:export-ydpi="96"> - <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.7071068" inkscape:cx="102.9673" inkscape:cy="-106.3048" inkscape:document-units="px" inkscape:current-layer="patternLayer" showgrid="false" units="px" inkscape:window-width="1280" inkscape:window-height="958" inkscape:window-x="0" inkscape:window-y="27" inkscape:window-maximized="1" fit-margin-top="0" fit-margin-left="0" fit-margin-right="0" fit-margin-bottom="0" borderlayer="true" /> - <defs id="defs4"> - <marker inkscape:stockid="Arrow2Mend" orient="auto" refY="0.0" refX="0.0" id="Arrow2Mend" style="overflow:visible;" inkscape:isstock="true"> - <path id="path19572" style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1" d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z " transform="scale(0.6) rotate(180) translate(0,0)" /> - </marker> - <marker inkscape:stockid="Arrow2Lend" orient="auto" refY="0.0" refX="0.0" id="Arrow2Lend" style="overflow:visible;" inkscape:isstock="true"> - <path id="path19566" style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1" d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z " transform="scale(1.1) rotate(180) translate(1,0)" /> - </marker> - <clipPath clipPathUnits="userSpaceOnUse" id="patternClipPath"> - <rect y="0" x="0" height="100" width="100" id="clipPathRect" style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#ffff00;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:20;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.09889996;stroke-opacity:1;marker:none;enable-background:accumulate" /> - </clipPath> - </defs> - <metadata id="metadata7"> - <rdf:RDF> - <cc:Work rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title></dc:title> - </cc:Work> - </rdf:RDF> - </metadata> - <inkscape:_templateinfo id="_templateinfo10"> - <inkscape:_name id="_name12">Seamless Pattern</inkscape:_name> - <inkscape:_shortdesc id="_shortdesc14">Seamless Pattern</inkscape:_shortdesc> - <inkscape:_keywords id="_keywords16">Seamless Pattern</inkscape:_keywords> - </inkscape:_templateinfo> - <g inkscape:groupmode="layer" id="patternLayer" inkscape:label="Pattern Layer"> - <use style="opacity:0.24100001" sodipodi:insensitive="true" height="100%" width="100%" id="phantomBottom" xlink:href="#designBottom" y="0" x="0" /> - <use style="opacity:0.24100001" sodipodi:insensitive="true" height="100%" width="100%" id="phantomTop" xlink:href="#designTop" y="0" x="0" /> - <g inkscape:label="Full Pattern" clip-path="url(#patternClipPath)" id="fullPattern"> - <g transform="scale(1.0,1.0)" inkscape:groupmode="layer" id="designBottom" inkscape:label="Design Bottom"> - <rect y="-7.105427e-15" x="0" height="100" width="100" id="rect9111" style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#ffb12a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.0989;stroke-opacity:1;marker:none;enable-background:accumulate" /> - </g> - <g transform="scale(1.0,1.0)" inkscape:groupmode="layer" id="designTop" inkscape:label="Design Top"> - <path id="text1784" d="M 3.238234,69.80676 C 3.159354,69.83297 3.094374,69.93222 3.036694,70.01073 2.660932,70.50659 2.509569,71.14994 2.275964,71.71774 1.916858,72.59433 1.496519,73.43397 1.155399,74.31888 0.8789607,74.26616 0.6222696,74.15725 0.3433261,74.12061 -2.244175,73.76628 -4.918972,74.23626 -7.312925,75.25835 -8.527103,75.75753 -9.63415,76.45362 -10.66688,77.26372 -12.75334,78.90125 -14.71033,80.75258 -16.23006,82.93048 -17.3402,84.57313 -18.32475,86.31708 -19.20132,88.09635 -19.89458,89.54883 -20.56114,91.10931 -20.71606,92.72675 -20.77582,93.54488 -20.69288,94.42704 -20.13513,95.07508 -19.48068,95.77388 -18.44182,95.96233 -17.53637,95.79024 -16.57723,95.60899 -15.86159,94.85437 -15.19381,94.19589 -13.31333,92.24569 -11.57624,90.07859 -10.52805,87.56107 -9.893955,86.045 -9.414104,84.39034 -9.622614,82.73138 -9.717263,82.12657 -9.822788,81.48673 -10.19986,80.99121 -10.44332,80.64384 -11.07786,80.68522 -11.29442,81.03796 -11.4565,81.30563 -11.52129,81.62288 -11.45154,81.93069 -11.07324,82.37787 -10.7417,82.99098 -10.71242,83.58887 -10.64261,84.76715 -11.02511,85.8442 -11.46405,86.91766 -12.21763,88.76234 -13.4137,90.42726 -14.71997,91.92279 -15.42483,92.71043 -16.17029,93.51774 -17.10023,94.04449 -17.50409,94.23627 -17.90814,94.34795 -18.35517,94.37584 -18.88829,94.29808 -19.13033,93.76945 -19.21284,93.28601 -19.34857,92.31026 -19.11882,91.36615 -18.82327,90.44575 -17.65221,87.05977 -15.65469,83.93067 -13.15757,81.37263 -11.79945,80.00732 -10.31271,78.80439 -8.677315,77.7798 -7.088768,76.82306 -5.334265,76.05826 -3.499093,75.76403 -2.117769,75.55863 -0.6818313,75.59706 0.6382789,76.10565 -0.1411339,77.75352 -0.9600896,79.3498 -1.7669,80.98437 -3.032205,83.51488 -4.262276,86.06052 -5.53533,88.58728 -6.677366,90.80843 -7.772719,93.06989 -8.822009,95.33603 -9.561548,96.97536 -10.27288,98.63291 -10.86176,100.3343 -11.31342,100.4077 -11.74775,100.4261 -12.19881,100.5037 -13.4671,100.7388 -14.81726,100.8803 -16.00473,101.4172 -17.84832,102.2804 -19.50816,103.5165 -20.89032,105.0125 -21.45263,105.6504 -22.04725,106.3526 -22.21588,107.2094 -22.32585,107.7275 -22.0502,108.2104 -21.72173,108.5849 -21.17062,109.2314 -20.25409,109.3835 -19.44738,109.2614 -18.29316,109.0913 -17.20712,108.6161 -16.2109,108.0271 -14.37604,106.8726 -12.84761,105.3125 -11.36962,103.7429 -10.77571,103.0841 -10.13793,102.4295 -9.678432,101.6655 -8.171192,101.4733 -6.61616,101.2244 -5.183592,100.7076 -3.893738,100.2593 -2.810482,99.48215 -1.78978,98.58038 0.0454981,96.95559 1.634338,95.00779 2.840713,92.87815 4.40117,90.12299 5.206009,87.01968 5.384976,83.86351 5.468634,82.22706 5.497595,80.52013 5.113899,78.91866 4.913043,78.00778 4.449005,77.23971 4.045635,76.41084 3.721181,75.87629 3.190872,75.46823 2.740653,75.03969 3.005348,74.33939 3.306751,73.58329 3.579811,72.88619 3.824769,72.23437 4.086687,71.60373 4.095858,70.89678 4.083882,70.63169 4.072056,70.39047 3.929562,70.16789 3.822473,69.92207 3.475146,69.72799 3.238234,69.80676 Z M 83.93502,29.09409 C 83.48973,29.40383 83.19721,29.92338 82.96926,30.39695 82.47058,31.58921 82.11941,32.807 81.77345,34.05256 81.76003,34.43451 81.4535,34.65896 81.16978,34.86676 79.67776,35.99334 77.97843,36.87902 76.32075,37.73199 74.83837,38.43589 73.28152,38.81272 71.70726,39.25801 69.97692,39.70952 68.19797,40.22636 66.52666,40.86841 64.006,41.82828 61.51395,43.08754 59.57633,45.00222 58.18365,46.38676 57.06058,48.10265 56.64514,50.04613 56.29211,51.68122 56.59486,53.39119 57.44213,54.82583 57.62278,55.13186 57.98678,55.35219 58.33625,55.18566 58.67851,55.06932 58.67095,54.70778 58.65622,54.41367 58.57143,53.59786 58.40533,52.75724 58.31799,51.94231 58.18525,50.43277 58.53914,48.88731 59.38851,47.63867 60.56654,45.88917 62.33683,44.62435 64.14996,43.59805 65.94927,42.55068 67.93413,41.91333 69.93526,41.37626 72.17527,40.82347 74.45739,40.17275 76.53144,39.14989 78.67526,38.07081 80.76744,36.80685 82.55012,35.18337 83.64975,34.18607 84.52399,32.99774 85.12504,31.64154 85.47305,30.82179 85.69191,29.76168 85.27196,28.92445 85.23932,28.86262 85.21325,28.89507 85.15009,28.8846 84.74478,28.8712 84.29884,28.89843 83.93502,29.09409 Z M 2.020873,76.8277 C 2.477441,77.31594 2.930471,77.84873 3.246245,78.44254 3.714701,79.36722 3.926223,80.37121 4.033126,81.39781 4.24343,83.65148 3.952563,85.87833 3.34072,88.05098 2.781297,90.09735 1.843627,92.12116 0.5755898,93.8236 -0.7359367,95.55539 -2.228323,97.10019 -4.102679,98.22875 -5.71508,99.20332 -7.572193,99.65321 -9.403897,100.002 -9.232936,99.41391 -9.001611,98.8188 -8.765237,98.25467 -7.60965,95.58417 -6.21738,93.06951 -4.875982,90.4891 -3.658174,88.26255 -2.501193,86.05293 -1.223671,83.86004 -0.0566712,81.56916 1.044488,79.20612 2.020873,76.8277 Z M 67.17132,47.35171 C 66.76308,47.8704 66.51385,48.54299 66.24877,49.14077 65.47765,51.06493 64.84574,53.04497 64.13271,54.99091 63.7556,54.91136 63.42384,54.83493 63.03727,54.83492 62.23242,54.89113 61.38296,54.9939 60.64806,55.33493 60.10544,55.56964 59.64559,56.1496 59.64253,56.7596 59.63005,57.41897 59.92278,58.02551 60.26076,58.58062 60.45345,58.88783 60.88475,58.99424 61.1946,58.81853 61.45325,58.6137 61.17132,58.20992 61.14904,57.92681 61.03188,57.51476 61.14806,56.94943 61.54772,56.70832 62.16395,56.36625 62.91437,56.30889 63.61353,56.37241 63.32011,57.20244 63.01228,58.01454 62.73549,58.85044 62.0531,60.86245 61.35157,62.87028 60.33594,64.74267 59.93025,65.43738 59.46542,66.22031 58.76543,66.65711 58.52183,66.85472 58.17762,66.684 58.11519,66.37705 57.99673,65.70711 58.22984,65.06064 58.22572,64.38981 58.2517,63.98395 57.72223,63.87362 57.4534,64.06948 56.98233,64.30223 56.94321,64.89906 56.89334,65.37032 56.85217,66.12001 56.83624,66.90919 57.02755,67.63979 57.12404,68.09649 57.55649,68.32765 57.96489,68.48609 58.30414,68.60732 58.68582,68.80454 59.01949,68.56125 60.15425,67.89242 60.88035,66.79208 61.51697,65.66884 62.32551,64.18947 62.95398,62.64533 63.55884,61.0757 64.11525,59.65075 64.54142,58.14964 64.99363,56.68888 65.40306,56.82184 65.82087,56.94653 66.25215,56.96547 67.4582,56.96762 68.65164,56.5129 69.73359,56.0137 70.23123,55.76412 70.70142,55.53013 71.14798,55.19466 71.45352,54.96511 71.5843,54.58699 71.38606,54.26114 71.27716,54.13945 71.07867,54.163 70.93973,54.18249 69.9597,54.44257 69.08751,54.94941 68.10745,55.21196 67.27461,55.49008 66.36117,55.46801 65.51309,55.30763 66.1013,53.66442 66.61772,51.9747 67.14734,50.31156 67.41753,49.40699 67.78297,48.53109 67.90238,47.59092 68.00702,47.13051 67.38792,47.10696 67.17132,47.35171 Z M 108.1807,29.20131 C 107.6051,29.41422 107.117,29.83928 106.6865,30.26381 105.4374,31.56914 104.5311,33.10356 103.6298,34.65967 102.9461,35.82215 102.3382,37.07235 101.826,38.31892 101.1339,40.02191 100.4983,41.74976 99.99003,43.51879 99.94113,43.7184 99.8376,43.92363 99.79077,44.12792 98.84396,45.1295 97.97419,46.23784 96.96986,47.18445 96.16778,47.95394 95.2272,48.53171 94.14093,48.82201 93.7798,48.9214 93.28034,48.9382 93.08536,48.54442 92.89507,48.07782 93.1183,47.62107 93.321,47.20491 93.77457,46.55611 94.25572,45.89997 94.64776,45.21063 95.34915,43.95083 96.10479,42.69472 96.53153,41.30807 96.6919,40.72151 96.84679,40.04361 96.52127,39.48362 96.35294,39.15885 95.87933,39.04051 95.54646,39.16481 95.17126,39.24054 94.98631,39.56153 94.78001,39.85839 93.83113,41.23354 93.00628,42.72385 92.33153,44.2508 91.80799,45.48856 91.29546,46.7891 91.25866,48.14908 91.25892,48.29959 91.36424,48.43752 91.38283,48.59421 90.56168,49.49216 89.77073,50.44889 88.88423,51.28418 88.08216,52.05364 87.14146,52.63147 86.05531,52.9217 85.69417,53.02109 85.19471,53.0379 84.99974,52.64412 84.94879,52.51929 84.91279,52.40599 84.9165,52.27946 84.96561,52.19686 84.9697,52.12471 84.99626,52.03586 85.01236,51.96506 84.97033,51.90239 84.99509,51.83303 85.06245,51.64392 85.15224,51.47517 85.23538,51.30459 85.68893,50.6558 86.16999,49.99973 86.56203,49.31037 87.26341,48.05059 88.01915,46.79441 88.4458,45.40781 88.60619,44.82125 88.7611,44.14335 88.43556,43.58335 88.26726,43.25857 87.87439,43.09927 87.54161,43.22355 87.16648,43.29924 86.90057,43.66127 86.69427,43.95812 85.74539,45.33329 84.92054,46.82362 84.24581,48.35056 83.72226,49.58832 83.29069,50.84779 83.25389,52.20774 83.25419,52.36295 83.27723,52.53273 83.297,52.69401 83.0902,52.9542 82.87271,53.17952 82.6525,53.4274 81.98686,54.23933 81.20789,54.96056 80.4352,55.66978 79.52323,56.50043 78.60448,57.33971 77.52903,57.9566 77.27163,58.09245 76.91885,58.33957 76.6782,58.08283 76.25816,57.41722 76.36821,56.54084 76.66566,55.85317 77.13904,54.73407 78.03775,53.81524 78.83855,52.92177 79.32515,52.33865 79.90413,51.86597 80.16647,51.13048 80.32163,50.75971 80.10539,50.32941 79.83608,50.07794 79.47169,49.7169 78.92066,49.85837 78.53921,50.12615 77.66843,50.74573 77.41277,51.89377 76.64753,52.61 76.40319,52.86414 75.95673,52.99575 75.67492,52.6963 75.37755,52.33182 75.16913,51.94824 74.89823,51.56539 74.51969,51.20773 73.98174,51.35038 73.60103,51.61321 73.1709,52.05722 72.99002,52.66849 72.79932,53.23963 72.48935,54.3367 72.20082,55.43787 72.04773,56.5685 71.97118,56.93358 72.09557,57.35756 72.3779,57.62036 72.62656,57.93388 73.12708,57.94125 73.43244,57.6957 73.6689,57.24551 73.76392,56.71794 73.91095,56.2337 74.0845,55.68385 74.17426,55.16767 74.42897,54.64945 74.7323,54.50346 75.15424,54.54143 75.48245,54.52192 75.87782,54.40855 75.66113,54.73847 75.60663,54.96706 75.32524,56.09386 74.88329,57.24876 74.81504,58.41775 74.75943,58.87593 75.09956,59.22886 75.50969,59.38682 76.11907,59.623 76.78559,59.68697 77.41612,59.53819 77.92907,59.34857 78.36284,58.99993 78.83054,58.71954 79.63819,58.22735 80.39933,57.56482 81.05024,56.88279 82.0294,55.90731 82.89918,54.87604 83.74919,53.7863 83.79708,53.83207 83.85519,53.86798 83.91199,53.90692 84.56024,54.31356 85.34202,54.30545 86.06217,54.13811 87.68586,53.73158 89.06277,52.68196 90.22349,51.52008 90.77095,50.9555 91.25183,50.33316 91.75405,49.72755 91.8028,49.77445 91.85878,49.80847 91.91696,49.84812 92.56512,50.2548 93.42776,50.2057 94.14792,50.03836 95.7715,49.63188 97.1485,48.58223 98.30923,47.42032 98.88444,46.82738 99.35569,46.14519 99.87965,45.50606 100.2102,46.0145 100.8115,46.40912 101.4249,46.34868 102.0458,46.29071 102.5312,45.84899 103.0422,45.52867 104.4532,44.53726 105.8571,43.44083 107.0371,42.18166 107.7948,41.3501 108.4375,40.42696 109.1713,39.57486 109.3343,39.38375 109.4234,39.17138 109.5732,38.96445 109.6298,39.00581 109.668,39.05564 109.7362,39.08527 110.3833,39.33254 111.1654,39.19044 111.762,38.87122 112.7627,38.29745 113.5898,37.49081 114.4259,36.70743 113.5389,39.03778 112.76,41.43194 111.9113,43.7761 111.8218,44.12393 111.5388,44.37274 111.3487,44.67136 110.2106,46.46564 109.0686,48.22045 107.9734,50.04217 106.8397,51.90262 105.8366,53.88061 104.9246,55.85656 104.0607,57.71558 103.3275,59.58472 102.7267,61.54526 102.3213,62.9044 101.9258,64.29807 101.8988,65.72592 101.9082,66.28827 101.9549,67.01408 102.435,67.38496 102.6994,67.55442 103.0027,67.77498 103.329,67.74484 103.6894,67.63286 104.0316,67.30766 104.2981,67.0503 105.2059,66.09114 105.7449,64.91276 106.2661,63.71469 106.7176,62.57886 107.1153,61.36553 107.5437,60.2207 108.7589,56.85497 110.0874,53.55282 111.2986,50.18564 112.2607,47.45298 113.1646,44.73879 114.05,41.98017 114.4573,41.4121 114.8815,40.79205 115.2972,40.2297 116.7119,38.28751 118.247,36.47027 119.7659,34.60961 120.5495,33.60475 121.4526,32.74335 122.3045,31.79781 122.4973,31.5321 122.8521,31.2488 122.8669,30.90254 122.8076,30.77858 122.6843,30.67173 122.5413,30.66145 122.1229,30.66273 121.8197,31.01338 121.5311,31.27519 119.7984,33.1008 117.9911,34.87942 116.2503,36.69709 116.1429,36.76571 115.8706,37.25761 115.968,36.94214 116.3247,35.65301 116.858,34.45592 117.3254,33.2042 117.5349,32.59512 117.726,31.9812 117.8013,31.33671 117.7517,31.03119 117.385,30.56977 117.0691,30.89476 116.4911,31.45351 116.1462,32.1441 115.7014,32.80829 115.0161,33.82808 114.356,34.87215 113.5695,35.82018 112.9283,36.57983 112.2103,37.32264 111.269,37.69813 110.9469,37.86201 110.4313,37.7062 110.4558,37.2973 110.4623,36.43839 110.6247,35.55864 110.8875,34.74062 111.1772,33.93152 111.6891,33.25908 112.0915,32.50409 112.2167,32.25076 112.4588,31.739 112.0457,31.61215 111.6951,31.60617 111.4368,31.92036 111.1974,32.14409 110.4807,32.91727 109.9029,33.85448 109.5097,34.82958 109.1703,35.73977 108.9541,36.65175 108.9981,37.62978 109.006,37.73603 109.0623,37.88322 109.0811,37.99423 108.6711,38.44428 108.2269,38.87602 107.8321,39.33916 107.2677,40.04676 106.6692,40.74804 106.019,41.37659 105.0479,42.32063 104.092,43.23131 102.9932,44.02892 102.6802,44.24286 102.266,44.52383 101.9,44.27827 101.46,43.91717 101.4888,43.32598 101.5673,42.82032 101.8072,41.5322 102.3693,40.26023 102.9247,39.08274 103.3761,38.34328 103.8801,37.63979 104.3724,36.92591 105.163,35.76854 106.1017,34.70217 106.9482,33.58697 107.4824,32.87444 108.0443,32.22551 108.5177,31.46984 108.8641,30.88824 109.1583,30.13553 108.8307,29.48139 108.7272,29.23142 108.4385,29.10665 108.1807,29.20131 Z M 7.621498,85.06715 C 7.191486,85.51111 7.01049,86.12243 6.819882,86.69351 6.509921,87.7906 6.221384,88.89176 6.068304,90.0224 5.991648,90.38753 6.115918,90.81156 6.398357,91.0743 6.647024,91.38782 7.147559,91.39518 7.452929,91.14964 7.689458,90.69939 7.784385,90.17187 7.931401,89.68762 8.104978,89.13778 8.275587,88.58059 8.530422,88.06235 8.833741,87.91636 9.174831,87.99533 9.502913,87.97584 9.898283,87.86246 9.681602,88.19241 9.627078,88.421 9.345822,89.54773 8.903765,90.70269 8.835607,91.87164 8.779901,92.32987 9.120133,92.68275 9.530157,92.84077 10.13957,93.07694 10.88704,93.09985 11.51745,92.95115 12.03041,92.76152 12.46419,92.41289 12.9319,92.13246 13.73951,91.6403 14.4198,91.01876 15.07072,90.33672 16.06905,89.34216 16.98686,88.31255 17.85051,87.19924 18.08362,87.54004 18.41915,87.81977 18.82772,87.92341 19.61025,88.16136 20.35528,87.83366 21.01415,87.42444 22.79301,86.34261 24.107,84.62492 25.08323,82.82045 25.33282,82.99638 25.60693,83.16703 25.85647,83.3431 26.24752,83.68648 26.79704,83.73919 27.27672,83.53796 28.85002,82.7973 30.21395,81.65469 31.35369,80.35266 31.65694,79.99013 31.94261,79.66163 32.23967,79.29339 32.24359,79.33158 32.19557,79.37687 32.19994,79.41547 32.22491,79.8844 32.45485,80.32583 32.81486,80.62826 33.22857,80.99148 33.7902,80.87219 34.2338,80.62036 35.16756,80.04423 36.06288,79.39762 36.93974,78.73999 38.59524,77.53051 39.93363,75.97451 41.25361,74.41808 41.3553,74.93754 41.51512,75.42092 41.708,75.91571 41.85499,76.37531 42.41611,76.46802 42.80471,76.27461 43.31249,75.99686 43.58025,75.4792 43.89232,75.01161 44.52866,73.95116 45.09268,72.83575 45.69846,71.7578 46.34609,70.50457 47.26975,69.37191 48.0708,68.21741 48.21919,67.94992 48.42901,67.68795 48.34962,67.36424 L 48.30867,67.28348 C 48.15001,66.91899 47.70875,66.89705 47.41587,67.12615 46.73318,67.59891 46.3009,68.30735 45.80433,68.95974 45.0634,70.00719 44.36857,71.09637 43.67347,72.17452 43.51578,72.41747 43.08394,72.07932 42.82175,72.09824 42.34832,72.03361 41.77416,71.91514 41.3628,72.22799 40.52614,72.93284 39.87904,73.82155 39.10574,74.59241 38.34527,75.41085 37.40279,76.06213 36.5638,76.79597 35.84055,77.40095 35.18856,78.03779 34.4251,78.59192 34.16987,78.78332 33.70068,78.74955 33.69388,78.35265 33.69094,77.81821 33.81705,77.33298 33.9286,76.81082 34.05276,76.60215 34.24547,76.3998 34.20883,76.16063 34.18318,76.10825 34.123,76.14956 34.08692,76.12067 34.06295,76.10161 34.0733,76.04997 34.04592,76.03979 34.25978,75.15131 34.66736,74.36649 35.0047,73.52057 35.0763,73.25159 35.29973,72.92187 35.08119,72.66898 34.80952,72.31317 34.34752,72.39951 34.02662,72.59366 33.64605,72.90674 33.41142,73.37433 33.22259,73.81453 32.88843,74.69576 32.67567,75.67974 32.38668,76.57615 32.24487,76.96509 32.183,77.30477 32.14977,77.71275 31.83529,78.10564 31.53617,78.49988 31.22396,78.8937 30.43712,79.97365 29.46699,80.89007 28.31991,81.58595 27.97609,81.7374 27.62962,82.169 27.22776,82.03807 26.95724,81.8786 26.78025,81.58058 26.73689,81.27044 26.72387,80.55901 27.10794,79.95548 27.37446,79.32056 27.4986,78.9801 27.76352,78.59582 27.73332,78.22402 27.58049,77.93847 27.30168,77.56393 26.91897,77.62031 26.47516,77.78763 26.19125,78.11213 25.95104,78.51768 25.7498,78.52613 25.39534,78.31876 25.13911,78.31973 24.35011,78.19437 23.58028,78.55471 22.91262,78.94013 20.95586,80.00235 19.12946,81.43443 18.07271,83.42749 17.66419,84.20022 17.37425,85.1045 17.43837,85.98516 17.19605,86.28738 16.9297,86.5927 16.67296,86.88133 16.00745,87.69323 15.30933,88.37345 14.53654,89.08271 13.62466,89.9133 12.70582,90.75265 11.63025,91.36961 11.37287,91.50545 11.02028,91.75247 10.77952,91.49576 10.3595,90.83016 10.46954,89.95377 10.76701,89.26609 11.24037,88.14699 12.05823,87.26918 12.85903,86.37571 13.34562,85.79257 14.00546,85.27889 14.2679,84.54336 14.42296,84.17265 14.12596,83.78329 13.85655,83.53187 13.49215,83.17085 12.94113,83.31232 12.55968,83.58006 11.68879,84.19972 11.43325,85.34773 10.66799,86.06394 10.42366,86.31809 9.9772,86.44969 9.695387,86.15023 9.398015,85.78575 9.270476,85.36115 8.99955,84.97832 8.621024,84.62067 8.002191,84.80431 7.621498,85.06715 Z M 23.36705,80.43787 C 23.62733,80.32281 24.01545,79.97978 24.21781,80.31171 24.27964,80.54748 24.32513,80.83897 24.30321,81.08134 24.18312,82.14142 23.57087,82.9761 22.93996,83.80526 22.23032,84.68345 21.48165,85.63928 20.52119,86.25171 20.24243,86.39668 19.95641,86.6106 19.63053,86.49987 19.28211,86.3057 19.18407,85.85417 19.21957,85.48887 19.33567,84.63474 19.79717,83.88548 20.30135,83.2122 21.15646,82.14275 22.16235,81.11721 23.36705,80.43787 Z M 125.4644,31.41515 C 124.9698,31.88179 124.8377,32.69702 125.2723,33.24079 125.6001,33.69737 126.2535,33.76626 126.7333,33.51647 127.3753,33.24344 127.5958,32.38709 127.2915,31.81041 127.214,31.65828 127.0829,31.48953 126.9647,31.36647 126.5853,30.93303 125.8809,31.07098 125.4644,31.41515 Z M -16.19586,103.4457 C -15.56289,103.1531 -14.88434,102.9329 -14.21329,102.7452 -13.40833,102.5351 -12.5489,102.413 -11.74327,102.2043 -12.19497,102.805 -12.82616,103.3047 -13.35588,103.835 -14.52763,104.9462 -15.68827,106.1065 -17.02736,107.0182 -17.6931,107.4338 -18.41637,107.7873 -19.17074,108.0031 -19.65434,108.1229 -20.24883,108.1305 -20.63171,107.7276 -20.95268,107.436 -20.58362,107.0466 -20.39383,106.7936 -19.66361,105.9247 -18.87594,105.2369 -17.97386,104.55 -17.41847,104.1231 -16.82921,103.7379 -16.19586,103.4457 Z M 110.2784,48.97495 C 110.2536,49.23137 110.1853,49.41662 110.1199,49.66528 109.75,50.9731 109.287,52.27989 108.8444,53.56442 107.6875,56.76135 106.5114,59.94915 105.371,63.15203 104.9852,64.13133 104.5649,65.12487 103.9679,65.99807 103.7836,66.21076 103.5143,66.71798 103.2006,66.48908 102.9263,66.2283 103.0385,65.76365 103.0728,65.4353 103.3839,63.58439 103.9103,61.81316 104.5022,60.03538 105.3395,57.4679 106.6145,55.08123 107.9073,52.71814 108.6328,51.42905 109.3355,50.12164 110.2784,48.97495 Z" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10px;line-height:100%;font-family:Pushkin;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" inkscape:connector-curvature="0" /> - <path id="path1790" d="M 84.87396,19.36488 79.88036,19.36488 79.88036,19.68443 80.02993,19.68443 C 80.70294,19.68443 80.77766,19.71861 80.77766,20.00411 L 80.77766,20.20111 80.77766,23.437 80.77766,23.63426 C 80.77766,23.91963 80.70294,23.95368 80.02993,23.95368 L 79.88036,23.95368 79.88036,24.27323 84.98192,24.27323 85.14811,22.45808 84.78249,22.45808 C 84.67467,22.93382 84.48334,23.35539 84.28405,23.55265 84.02638,23.82451 83.5528,23.95368 82.85493,23.95368 L 82.30649,23.95368 C 82.05721,23.95368 81.84953,23.91301 81.77468,23.85167 81.71671,23.81113 81.70834,23.77019 81.70834,23.62751 L 81.70834,21.89397 81.87453,21.89397 C 82.38121,21.89397 82.58902,21.93464 82.75535,22.07733 82.97113,22.25433 83.05436,22.47186 83.07098,22.87275 L 83.46146,22.87275 83.46146,20.64307 83.07098,20.64307 C 83.02936,21.30933 82.69698,21.57443 81.90763,21.57443 L 81.70834,21.57443 81.70834,20.02438 C 81.70834,19.73212 81.78319,19.68443 82.23177,19.68443 L 82.66374,19.68443 C 83.39499,19.68443 83.75223,19.74577 84.03489,19.93615 84.30904,20.11288 84.50834,20.4935 84.63305,21.1053 L 84.99043,21.1053 84.87396,19.36488 Z M 73.84798,22.09097 74.7869,22.09097 C 75.53477,22.09097 75.92525,22.04341 76.25777,21.91438 76.84755,21.68306 77.17993,21.24799 77.17993,20.71104 77.17993,20.19462 76.88903,19.80009 76.34073,19.57579 76.01672,19.44 75.50153,19.36488 74.92823,19.36488 L 72.02014,19.36488 72.02014,19.68443 72.16971,19.68443 C 72.84272,19.68443 72.91744,19.71861 72.91744,20.00411 L 72.91744,20.20111 72.91744,23.437 72.91744,23.63426 C 72.91744,23.91963 72.84272,23.95368 72.16971,23.95368 L 72.02014,23.95368 72.02014,24.27323 74.8119,24.27323 74.8119,23.95368 74.59571,23.95368 C 73.9227,23.95368 73.84798,23.91963 73.84798,23.63426 L 73.84798,23.437 73.84798,22.09097 Z M 73.84798,21.77156 73.84798,20.03127 C 73.84798,19.71861 73.89798,19.68443 74.35494,19.68443 L 74.88675,19.68443 C 75.75082,19.68443 76.15792,20.01762 76.15792,20.73819 76.15792,21.4385 75.7342,21.77156 74.85351,21.77156 L 73.84798,21.77156 Z M 66.61929,19.26989 66.27043,19.26989 64.35921,23.23297 C 64.19316,23.58657 64.15992,23.63426 64.03534,23.7429 63.90225,23.87207 63.66958,23.95368 63.44516,23.95368 L 63.41205,23.95368 63.41205,24.27323 65.6139,24.27323 65.6139,23.95368 65.44757,23.95368 C 64.99912,23.95368 64.77469,23.82451 64.77469,23.5663 64.77469,23.48456 64.79969,23.38957 64.84941,23.2808 L 65.1237,22.68251 67.32554,22.68251 67.77426,23.59346 C 67.82412,23.69547 67.84074,23.7429 67.84074,23.77708 67.84074,23.88571 67.6328,23.95368 67.32554,23.95368 L 66.97654,23.95368 66.97654,24.27323 69.55238,24.27323 69.55238,23.95368 69.43605,23.95368 C 69.02043,23.95368 68.9291,23.89936 68.73804,23.51874 L 66.61929,19.26989 Z M 66.21219,20.38473 67.15097,22.3154 65.28976,22.3154 66.21219,20.38473 Z M 60.47896,19.31745 60.1632,19.31745 59.83095,19.71861 C 59.24076,19.36488 58.91702,19.263 58.36021,19.263 57.55425,19.263 56.88948,19.52823 56.32456,20.07869 55.79274,20.59538 55.54346,21.16638 55.54346,21.86668 55.54346,23.32836 56.71491,24.37524 58.35197,24.37524 59.68137,24.37524 60.52882,23.73614 60.72001,22.59401 L 60.32952,22.53969 C 60.24643,22.90005 60.14658,23.1446 59.997,23.34863 59.65651,23.81775 59.1247,24.05582 58.45155,24.05582 57.22186,24.05582 56.64033,23.35539 56.64033,21.89397 56.64033,21.12557 56.76477,20.60902 57.04729,20.20111 57.30496,19.82049 57.82002,19.58242 58.35197,19.58242 58.93351,19.58242 59.4487,19.834 59.76447,20.26921 59.92229,20.4935 60.047,20.7586 60.23819,21.28204 L 60.6034,21.28204 60.47896,19.31745 Z M 52.16178,19.32421 51.85439,19.32421 51.52201,19.73212 C 51.13139,19.42622 50.59971,19.263 50.00979,19.263 48.9213,19.263 48.19019,19.834 48.19019,20.68401 48.19019,21.42485 48.63864,21.79196 49.86009,22.0503 L 50.64943,22.21352 C 51.26434,22.34256 51.32244,22.3562 51.49701,22.46511 51.7463,22.6213 51.87925,22.84559 51.87925,23.11083 51.87925,23.38268 51.75454,23.60697 51.50539,23.79073 51.2311,23.98773 50.95709,24.06258 50.49999,24.06258 49.88508,24.06258 49.44474,23.90612 49.05426,23.55265 48.70525,23.23297 48.53082,22.91356 48.40624,22.39012 L 48.04886,22.39012 48.0821,24.32768 48.40624,24.32768 48.77997,23.86531 C 49.33665,24.23918 49.80226,24.37524 50.52486,24.37524 51.7463,24.37524 52.5274,23.79073 52.5274,22.87951 52.5274,22.45808 52.35284,22.09786 52.02896,21.83952 51.80454,21.66279 51.48053,21.54713 50.81562,21.41121 L 49.92656,21.22772 C 49.18721,21.07139 48.83821,20.80616 48.83821,20.39149 48.83821,19.91575 49.31179,19.58917 50.01804,19.58917 50.59971,19.58917 51.07315,19.79333 51.40554,20.18071 51.64659,20.45945 51.79602,20.74495 51.90425,21.09166 L 52.2615,21.09166 52.16178,19.32421 Z M 40.92813,22.0503 40.92813,20.20111 40.92813,20.00411 C 40.92813,19.71861 41.00271,19.68443 41.67586,19.68443 L 41.83381,19.68443 41.83381,19.36488 39.10015,19.36488 39.10015,19.68443 39.24972,19.68443 C 39.92273,19.68443 39.99732,19.71861 39.99732,20.00411 L 39.99732,20.20111 39.99732,23.437 39.99732,23.63426 C 39.99732,23.91963 39.92273,23.95368 39.24972,23.95368 L 39.10015,23.95368 39.10015,24.27323 41.83381,24.27323 41.83381,23.95368 41.67586,23.95368 C 41.00271,23.95368 40.92813,23.91963 40.92813,23.63426 L 40.92813,23.437 40.92813,22.57374 41.89191,21.77832 43.33765,23.51185 C 43.47074,23.67493 43.50384,23.72939 43.50384,23.79748 43.50384,23.90612 43.34616,23.95368 42.93892,23.95368 L 42.68126,23.95368 42.68126,24.27323 45.52287,24.27323 45.52287,23.95368 45.36506,23.95368 C 44.9081,23.95368 44.79163,23.90612 44.55072,23.61386 L 42.54006,21.24123 43.77812,20.2284 C 44.17685,19.8817 44.68367,19.68443 45.18225,19.68443 L 45.18225,19.36488 42.62302,19.36488 42.62302,19.68443 42.83096,19.68443 C 43.21321,19.68443 43.37089,19.74577 43.37089,19.88845 43.37089,19.98357 43.20469,20.18071 42.96378,20.37784 L 40.92813,22.0503 Z M 31.63866,19.36488 29.92701,19.36488 29.92701,19.68443 30.13482,19.68443 C 30.55854,19.68443 30.74973,19.73888 30.89917,19.90899 L 30.89917,22.79803 C 30.89917,23.72939 30.73298,23.92652 29.93539,23.95368 L 29.93539,24.27323 32.30356,24.27323 32.30356,23.95368 C 31.51394,23.92652 31.34789,23.72939 31.34789,22.79803 L 31.34789,20.27596 35.05384,24.36848 35.40271,24.36848 35.40271,20.84021 C 35.40271,19.90899 35.56877,19.71172 36.36649,19.68443 L 36.36649,19.36488 33.99845,19.36488 33.99845,19.68443 C 34.7878,19.71172 34.95399,19.90899 34.95399,20.84021 L 34.95399,22.97476 31.63866,19.36488 Z M 26.23795,20.20111 26.23795,20.00411 C 26.23795,19.71861 26.31267,19.68443 26.9773,19.68443 L 27.14349,19.68443 27.14349,19.36488 24.39335,19.36488 24.39335,19.68443 24.55954,19.68443 C 25.23255,19.68443 25.30727,19.71861 25.30727,20.00411 L 25.30727,20.20111 25.30727,23.437 25.30727,23.63426 C 25.30727,23.91963 25.23255,23.95368 24.55954,23.95368 L 24.39335,23.95368 24.39335,24.27323 27.14349,24.27323 27.14349,23.95368 26.9773,23.95368 C 26.31267,23.95368 26.23795,23.91963 26.23795,23.63426 L 26.23795,23.437 26.23795,20.20111 Z" style="fill:#000000;fill-opacity:1;stroke-width:1pt" inkscape:connector-curvature="0" /> - <rect inkscape:export-ydpi="475.20001" inkscape:export-xdpi="475.20001" inkscape:export-filename="/home/d/ink/draw-freely.png" ry="0.0000000" rx="1.468345" y="34.87875" x="-34.9314" height="25.7114" width="28.82679" id="rect2417" style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:none;stroke-width:1.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1" /> - <g transform="matrix(0.1106013,0,0,0.1106013,31.33167,72.44851)" id="inkscape-logo"> - <path id="path2313" d="M 163.15,27.83 28.81,165.3 C -16.58,221.51 59.7,214.97 92.4,231.16 104.13,243.15 47.44,252 59.17,264 70.9,275.99 130.1,287.1 141.85,299.09 153.58,311.08 117.84,323.8 129.57,335.79 141.3,347.78 168.43,336.42 173.51,364.1 177.13,383.88 222.4,372.6 244.54,356.4 256.27,344.4 222.1,345.53 233.83,333.54 263,303.71 290.16,322.7 300.14,292.81 305.07,278.04 257.2,270.04 268.95,258.05 302.7,238.34 419.35,225.51 364,170.16 L 224.75,27.83 C 207.72,11.48 179.3,11.3 163.15,27.83 Z M 317.46,292.81 C 317.46,299.63 367.71,304.1 367.71,291.2 360.55,270.48 323.4,271.88 317.46,292.81 Z M 91.1,329.05 C 103,339.34 121.38,326.49 126.89,312.13 115.36,296.81 72.2,312.68 91.1,329.05 Z M 311.16,306.82 C 295.82,320.58 312.88,334.54 328,325.65 331.37,322.23 327.91,310.24 311.16,306.82 Z" inkscape:connector-curvature="0" /> - <path style="fill:#ffffff" id="path2315" d="M 131,238.6 C 134.59,240.83 188.89,251.86 202.16,254.06 206.76,255.03 203.5,259.77 197.16,262.97 182.86,266.77 113.5,238.6 131,238.6 Z" inkscape:connector-curvature="0" /> - <path style="fill:#ffffff" id="path2317" d="M 216.63,37.47 269.78,91.45 C 274.82,96.6 274.75,106.58 271.93,109.45 L 245.54,88.34 240.35,119.6 218.3,107.96 182.99,130.27 171.3,83.24 152.33,116.06 123.33,116.06 C 111.51,116.06 110.12,101.06 120.86,90.32 139.62,70.07 161.15,49.43 172.85,37.47 184.61,25.45 205.1,25.79 216.63,37.47 Z" inkscape:connector-curvature="0" /> - </g> - </g> - <g sodipodi:insensitive="true" id="designBottomGenerator"> - <use height="100%" width="100%" id="bottom1" transform="translate(-100,-100)" xlink:href="#designBottom" y="0" x="0" /> - <use height="100%" width="100%" id="bottom2" transform="translate(0,-100)" xlink:href="#designBottom" y="0" x="0" /> - <use height="100%" width="100%" id="bottom3" transform="translate(100,-100)" xlink:href="#designBottom" y="0" x="0" /> - <use height="100%" width="100%" id="bottom4" transform="translate(-100,0)" xlink:href="#designBottom" y="0" x="0" /> - <use height="100%" width="100%" id="bottom5" transform="translate(0,0)" xlink:href="#designBottom" y="0" x="0" /> - <use height="100%" width="100%" id="bottom6" transform="translate(100,0)" xlink:href="#designBottom" y="0" x="0" /> - <use height="100%" width="100%" id="bottom7" transform="translate(-100,100)" xlink:href="#designBottom" y="0" x="0" /> - <use height="100%" width="100%" id="bottom8" transform="translate(0,100)" xlink:href="#designBottom" y="0" x="0" /> - <use transform="translate(100,100)" height="100%" width="100%" id="bottom9" xlink:href="#designBottom" y="0" x="0" /> - </g> - <g sodipodi:insensitive="true" id="designTopGenerator"> - <use height="100%" width="100%" id="top1" transform="translate(-100,-100)" xlink:href="#designTop" y="0" x="0" /> - <use height="100%" width="100%" id="top2" transform="translate(0,-100)" xlink:href="#designTop" y="0" x="0" /> - <use height="100%" width="100%" id="top3" transform="translate(100,-100)" xlink:href="#designTop" y="0" x="0" /> - <use height="100%" width="100%" id="top4" transform="translate(-100,0)" xlink:href="#designTop" y="0" x="0" /> - <use height="100%" width="100%" id="top5" transform="translate(0,0)" xlink:href="#designTop" y="0" x="0" /> - <use height="100%" width="100%" id="top6" transform="translate(100,0)" xlink:href="#designTop" y="0" x="0" /> - <use height="100%" width="100%" id="top7" transform="translate(-100,100)" xlink:href="#designTop" y="0" x="0" /> - <use height="100%" width="100%" id="top8" transform="translate(0,100)" xlink:href="#designTop" y="0" x="0" /> - <use transform="translate(100,100)" height="100%" width="100%" id="top9" xlink:href="#designTop" y="0" x="0" /> - </g> - </g> - <g id="preview"> - <use x="0" y="0" xlink:href="#fullPattern" id="fullPatternClone" transform="translate(200,-100)" width="100" height="100" inkscape:tile-cx="50" inkscape:tile-cy="50" inkscape:tile-w="100" inkscape:tile-h="100" inkscape:tile-x0="100" inkscape:tile-y0="100" /> - <use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" id="mainClonePreview" /> - <use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(0,100)" id="clonePreview1" /> - <use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(0,200)" id="clonePreview2" /> - <use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(100,0)" id="clonePreview3" /> - <use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(100,100)" id="clonePreview4" /> - <use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(100,200)" id="clonePreview5" /> - <use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(200, 0)" id="clonePreview6" /> - <use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(200,100)" id="clonePreview7" /> - <use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(200,200)" id="clonePreview8" /> - </g> - <text sodipodi:linespacing="125%" id="text8664" y="-188.93137" x="-191.40367" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:23.6686153px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:Verdana;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" xml:space="preserve"><tspan y="-188.93137" x="-191.40367" id="tspan8666" sodipodi:role="line" style="-inkscape-font-specification:'sans-serif Bold';font-family:sans-serif;font-weight:bold;font-style:normal;font-stretch:normal;font-variant:normal">Seamless pattern</tspan></text> - <flowRoot transform="translate(-711.513,-78.2254)" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" id="infoText" xml:space="preserve"><flowRegion id="flowRegion11597"><rect style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:sans-serif" y="-99.85437" x="519.1747" height="326.1553" width="228.5243" id="rect11599" /></flowRegion><flowPara style="font-size:14.666667px" id="flowPara11613">You can use "design top" layer and "design bottom" layer inside this seamless pattern to design.</flowPara><flowPara style="font-size:14.666667px" id="flowPara12265" /><flowPara style="font-size:14.666667px" id="flowPara11609">Go to Patern -root- layer to use the seamless patern.</flowPara></flowRoot> <path style="color:#000000;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3.7795277;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-end:url(#Arrow2Mend);paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" d="M -204,-194 C -204,-194 -260.3514,-151.8886 -234.2721,-53.49747 -201.2516,71.08073 -72.34315,47.12994 -72.34315,47.12994" id="path19539" inkscape:connector-curvature="0" sodipodi:nodetypes="csc" /> - </g> +<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="100px" height="100px" viewBox="0 0 100 100" id="SVGRoot" version="1.1" inkscape:version="0.91+devel r14699 custom" sodipodi:docname="seamless_pattern.svg" inkscape:export-xdpi="96" inkscape:export-ydpi="96" enable-background="new"> +<defs id="defs4787"> +<linearGradient inkscape:collect="always" id="linearGradient4217"> +<stop style="stop-color:#ffffff;stop-opacity:1" offset="0" id="stop4213" /> +<stop style="stop-color:#ffffff;stop-opacity:0.21960784" offset="1" id="stop4215" /> +</linearGradient> +<clipPath clipPathUnits="userSpaceOnUse" id="patternClipPath"> +<rect y="0" x="0" height="100" width="100" id="clipPathRect" style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#ffff00;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:20;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.09889996;stroke-opacity:1;marker:none;enable-background:accumulate" /> +</clipPath> +<marker inkscape:stockid="Arrow2Mend" orient="auto" refY="0.0" refX="0.0" id="Arrow2Mend" style="overflow:visible;" inkscape:isstock="true"> +<path id="path19572" style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1" d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z " transform="scale(0.6) rotate(180) translate(0,0)" /> +</marker> +<radialGradient inkscape:collect="always" xlink:href="#linearGradient4217" id="radialGradient4159" gradientUnits="userSpaceOnUse" cx="50" cy="50" fx="50" fy="50" r="50" /> +</defs> +<sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.93166" inkscape:cx="98.45167" inkscape:cy="143.1829" inkscape:document-units="px" inkscape:current-layer="patternLayer" showgrid="false" inkscape:pagecheckerboard="true" inkscape:snap-global="false" /> +<metadata id="metadata4790"> +<rdf:RDF> +<cc:Work rdf:about=""> +<dc:format>image/svg+xml</dc:format> +<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> +<dc:title></dc:title> +</cc:Work> +</rdf:RDF> +</metadata> +<g inkscape:groupmode="layer" id="patternLayer" inkscape:label="Pattern" style="display:inline"> +<g id="g8891" sodipodi:insensitive="true"> +<use x="0" y="0" xlink:href="#fullPattern" id="fullPatternClone" transform="translate(200,-100)" width="100" height="100" inkscape:tile-cx="50" inkscape:tile-cy="50" inkscape:tile-w="100" inkscape:tile-h="100" inkscape:tile-x0="100" inkscape:tile-y0="100" /> +<use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(0,100)" id="clonePreview1" /> +<use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(0,200)" id="clonePreview2" /> +<use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(100)" id="clonePreview3" /> +<use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(100,100)" id="clonePreview4" /> +<use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(100,200)" id="clonePreview5" /> +<use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(200)" id="clonePreview6" /> +<use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(200,100)" id="clonePreview7" /> +<use height="100%" width="100%" x="0" y="0" inkscape:tiled-clone-of="#fullPatternClone" xlink:href="#fullPatternClone" transform="translate(200,200)" id="clonePreview8" /> +</g> +<use style="opacity:0.3" height="100%" width="100%" id="phantomBottom" xlink:href="#designBottom" y="0" x="0" sodipodi:insensitive="true" /> +<use style="opacity:0.3" height="100%" width="100%" id="phantomTop" xlink:href="#designTop" y="0" x="0" sodipodi:insensitive="true" /> +<g id="infoGroup" sodipodi:insensitive="true"> +<rect style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:74.66007233;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" id="rect4130" width="526.66248" height="338.53928" x="-348.83969" y="-380.86212" /> +<text xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:23.66861534px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:Verdana;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none" x="-326.82172" y="-349.80621" id="text8664" sodipodi:linespacing="125%"><tspan style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold'" sodipodi:role="line" id="tspan8666" x="-326.82172" y="-349.80621">Seamless pattern</tspan></text> +<flowRoot xml:space="preserve" id="infoText" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.75px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none" transform="translate(-709.3014,-231.7039)"><flowRegion id="flowRegion11597"><rect ry="0.97061312" id="rect11599" width="491.7114" height="324.99371" x="383.75671" y="-110.4523" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.75px;font-family:sans-serif;-inkscape-font-specification:sans-serif" /></flowRegion><flowPara style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.5px;font-family:Cantarell;-inkscape-font-specification:Cantarell" id="flowPara6756">Use the layers "<flowSpan style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Cantarell;-inkscape-font-specification:'Cantarell Bold'" id="flowSpan7476">Pattern Foreground</flowSpan>" and "<flowSpan style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Cantarell;-inkscape-font-specification:'Cantarell Bold'" id="flowSpan7478">Pattern Background</flowSpan>" on the pattern page to create your design. The separation into two layers will make it easier for you to create and edit overlapping content like a foreground drawing with a background fill.</flowPara><flowPara style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.5px;font-family:Cantarell;-inkscape-font-specification:Cantarell" id="flowPara7456" /><flowPara style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.5px;font-family:Cantarell;-inkscape-font-specification:Cantarell" id="flowPara7458">The layer named "<flowSpan style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Cantarell;-inkscape-font-specification:'Cantarell Bold'" id="flowSpan7480">Pattern</flowSpan>" is for using the seamless pattern, copying it to other documents, adding opacity etc. </flowPara><flowPara style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.5px;font-family:Cantarell;-inkscape-font-specification:Cantarell" id="flowPara7460">Select the group on the page, and use <flowSpan style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Cantarell;-inkscape-font-specification:'Cantarell Bold'" id="flowSpan7484">Object->Pattern->Objects to Pattern</flowSpan> to convert your creation into a fill pattern.</flowPara><flowPara style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.5px;font-family:Cantarell;-inkscape-font-specification:Cantarell" id="flowPara7462" /><flowPara style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.5px;font-family:Cantarell;-inkscape-font-specification:Cantarell" id="flowPara7464">The layer "<flowSpan style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Cantarell;-inkscape-font-specification:'Cantarell Bold'" id="flowSpan7482">Preview Background</flowSpan>" provides an easy way to preview your creation if it contains transparency.</flowPara><flowPara style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.5px;font-family:Cantarell;-inkscape-font-specification:Cantarell" id="flowPara7466">Changing this layer's visibility will not alter the pattern.</flowPara><flowPara style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.5px;font-family:Cantarell;-inkscape-font-specification:Cantarell" id="flowPara7468" /><flowPara style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.5px;font-family:Cantarell;-inkscape-font-specification:Cantarell" id="flowPara7470">If an object is moved outside the pattern/page limits, it will be difficult to select it. </flowPara><flowPara style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.5px;font-family:Cantarell;-inkscape-font-specification:Cantarell" id="flowPara7472">To move it back onto the page, select the object using the rubberband selection (click and drag a selection box) with the selection tool.</flowPara><flowPara style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12.5px;font-family:Cantarell;-inkscape-font-specification:Cantarell" id="flowPara7474">Then move it back onto the page, using the arrow keys or the "Align and Distribute" dialog (Shift+Ctrl+A).</flowPara></flowRoot><path sodipodi:nodetypes="cccc" inkscape:connector-curvature="0" id="path19539" d="m -354.4906,-359.49 h -6.1704 V 51.51566 h 229.6052" style="color:#000000;text-decoration:none;text-decoration-line:none;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#000000;stroke-width:3.77952766;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-end:url(#Arrow2Mend);enable-background:accumulate" /> +</g> +<g id="textPreview" sodipodi:insensitive="true"> +<path d="m -29.56541,100 0,-7.16704 2.00731,0 0,4.51126 1.91761,0 0,-4.24223 2.00731,0 0,4.24223 4.36647,0 0,2.65578 -10.2987,0 z" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:medium;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" id="path9845" inkscape:connector-curvature="0" /> +<path d="m -22.7433,87.81814 q 0,0.77256 0.26214,1.16575 0.26214,0.38628 0.77256,0.38628 0.46906,0 0.73808,-0.3104 0.26214,-0.31731 0.26214,-0.87604 0,-0.6967 -0.49667,-1.17266 -0.50355,-0.47596 -1.25547,-0.47596 l -0.28278,0 0,1.28303 z m -0.93124,-3.7732 4.40783,0 0,2.49017 -1.14504,0 q 0.70359,0.49666 1.02773,1.11747 0.31735,0.62082 0.31735,1.51066 0,1.20024 -0.69671,1.95213 -0.70359,0.74498 -1.82103,0.74498 -1.35893,0 -1.99355,-0.93123 -0.63462,-0.93812 -0.63462,-2.93854 l 0,-1.45547 -0.19316,0 q -0.58628,0 -0.8553,0.46216 -0.2759,0.46217 -0.2759,1.44168 0,0.79327 0.15859,1.47617 0.15868,0.6829 0.47603,1.26923 l -1.88321,0 q -0.19317,-0.79327 -0.28966,-1.59344 -0.10355,-0.80016 -0.10355,-1.60033 0,-2.09008 0.82778,-3.01441 0.8209,-0.93123 2.67642,-0.93123 z" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:medium;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" id="path9847" inkscape:connector-curvature="0" /> +<path d="m -26.75105,75.72598 1.87625,0 q -0.33111,0.79327 -0.49658,1.53136 -0.16556,0.73808 -0.16556,1.39338 0,0.7036 0.17932,1.04849 0.17243,0.338 0.53803,0.338 0.29663,0 0.45531,-0.25522 0.15858,-0.26212 0.23453,-0.93122 l 0.0624,-0.43458 q 0.2415,-1.89694 0.79329,-2.55225 0.55189,-0.65531 1.73142,-0.65531 1.23474,0 1.85551,0.91054 0.62086,0.91053 0.62086,2.7178 0,0.76568 -0.12419,1.58654 -0.11722,0.81396 -0.35872,1.67621 l -1.87624,0 q 0.35872,-0.73809 0.53803,-1.51067 0.17941,-0.77947 0.17941,-1.57963 0,-0.72429 -0.20005,-1.08988 -0.20004,-0.3656 -0.59325,-0.3656 -0.33111,0 -0.4897,0.25524 -0.16555,0.24832 -0.25525,1.00019 l -0.055,0.43458 q -0.20692,1.64862 -0.76568,2.31082 -0.55868,0.66221 -1.69684,0.66221 -1.22787,0 -1.82112,-0.84156 -0.59325,-0.84155 -0.59325,-2.57984 0,-0.6829 0.10355,-1.43477 0.10346,-0.75188 0.32415,-1.63483 z" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:medium;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" id="path9849" inkscape:connector-curvature="0" /> +<path d="m -29.18596,70.67666 2.19351,0 0,-2.54535 1.7659,0 0,2.54535 3.27654,0 q 0.53804,0 0.7312,-0.21383 0.1862,-0.21384 0.1862,-0.84846 l 0,-1.26922 1.7659,0 0,2.11768 q 0,1.46237 -0.60701,2.07628 -0.61398,0.60703 -2.07629,0.60703 l -3.27654,0 0,1.22784 -1.7659,0 0,-1.22784 -2.19351,0 0,-2.46948 z" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:medium;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" id="path9851" inkscape:connector-curvature="0" /> +<path d="m -20.38415,59.23292 4.05599,0 0,2.46948 -10.66429,0 0,-2.46948 1.13128,0 q -0.67598,-0.51044 -0.99334,-1.13127 -0.32423,-0.62081 -0.32423,-1.42788 0,-1.42787 1.13826,-2.3453 1.13119,-0.91744 2.91782,-0.91744 1.78654,0 2.92471,0.91744 1.13128,0.91743 1.13128,2.3453 0,0.80707 -0.31735,1.42788 -0.32414,0.62083 -1.00013,1.13127 z m -5.00108,-1.64171 q 0,0.79327 0.58637,1.22093 0.5794,0.42078 1.6762,0.42078 1.09671,0 1.68308,-0.42078 0.5794,-0.42766 0.5794,-1.22093 0,-0.79327 -0.5794,-1.20715 -0.5794,-0.42078 -1.68308,-0.42078 -1.10368,0 -1.68317,0.42078 -0.5794,0.41388 -0.5794,1.20715 z" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:medium;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" id="path9853" inkscape:connector-curvature="0" /> +<path d="m -24.88856,45.83706 q -0.1518,0.3242 -0.22077,0.6484 -0.0761,0.31731 -0.0761,0.64151 0,0.95193 0.61389,1.46927 0.6071,0.51045 1.74526,0.51045 l 3.55932,0 0,2.46948 -7.72574,0 0,-2.46948 1.26923,0 q -0.7588,-0.47595 -1.10367,-1.08988 -0.35185,-0.62081 -0.35185,-1.48306 0,-0.12416 0.0138,-0.26902 0.009,-0.14486 0.0413,-0.42078 l 2.23496,-0.007 z" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:medium;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" id="path9855" inkscape:connector-curvature="0" /> +<path d="m -23.15027,36.88348 0.7036,0 0,5.77361 q 0.86914,-0.0897 1.30372,-0.62772 0.43457,-0.53804 0.43457,-1.50375 0,-0.77948 -0.22765,-1.59344 -0.23453,-0.82086 -0.70359,-1.6831 l 1.90385,0 q 0.33111,0.87604 0.49667,1.75208 0.17243,0.87604 0.17243,1.75209 0,2.09698 -1.06231,3.26274 -1.06919,1.15886 -2.99368,1.15886 -1.89009,0 -2.97304,-1.13817 -1.08304,-1.14506 -1.08304,-3.14547 0,-1.82107 1.0968,-2.91095 1.0968,-1.09678 2.93167,-1.09678 z m -0.8209,2.53846 q -0.70359,0 -1.13119,0.41388 -0.43458,0.40698 -0.43458,1.06918 0,0.71739 0.40697,1.16576 0.40009,0.44836 1.1588,0.55873 l 0,-3.20755 z" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:medium;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" id="path9857" inkscape:connector-curvature="0" /> +<path d="m -26.99245,35.99364 0,-2.46947 5.33907,-1.92454 -5.33907,-1.91764 0,-2.47637 7.72574,3.04201 0,2.7109 -7.72574,3.03511 z" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:medium;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" id="path9859" inkscape:connector-curvature="0" /> +<path d="m -26.99245,25.80534 0,-2.46948 7.72574,0 0,2.46948 -7.72574,0 z m -3.00753,0 0,-2.46948 2.01419,0 0,2.46948 -2.01419,0 z" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:medium;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" id="path9861" inkscape:connector-curvature="0" /> +<path d="m -23.15027,13.23722 0.7036,0 0,5.77361 q 0.86914,-0.0897 1.30372,-0.62772 0.43457,-0.53805 0.43457,-1.50376 0,-0.77947 -0.22765,-1.59344 -0.23453,-0.82085 -0.70359,-1.6831 l 1.90385,0 q 0.33111,0.87604 0.49667,1.75208 0.17243,0.87605 0.17243,1.75209 0,2.09698 -1.06231,3.26275 -1.06919,1.15885 -2.99368,1.15885 -1.89009,0 -2.97304,-1.13816 -1.08304,-1.14506 -1.08304,-3.14548 0,-1.82106 1.0968,-2.91094 1.0968,-1.09678 2.93167,-1.09678 z m -0.8209,2.53845 q -0.70359,0 -1.13119,0.41389 -0.43458,0.40697 -0.43458,1.06918 0,0.71738 0.40697,1.16575 0.40009,0.44837 1.1588,0.55874 l 0,-3.20756 z" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:medium;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" id="path9863" inkscape:connector-curvature="0" /> +<path d="m -26.99245,12.06456 0,-2.400495 5.32522,-1.29682 -5.32522,-1.303718 0,-2.062494 5.2701,-1.29682 -5.2701,-1.303717 0,-2.4004958732508 L -19.26671,2.034903 l 0,2.697109 -5.31147,1.303717 5.31147,1.296819 0,2.697112 -7.72574,2.0349 z" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:medium;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" id="path9865" inkscape:connector-curvature="0" /> +</g> +<g inkscape:label="Helper Layer (don't use)" clip-path="url(#patternClipPath)" id="fullPattern" style="display:inline"> +<g inkscape:groupmode="layer" id="designBottom" inkscape:label="Pattern Background"> +<rect y="0" x="0" height="100" width="100" id="rect9111" style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:url(#radialGradient4159);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;marker:none;enable-background:accumulate" /> +</g> +<g inkscape:groupmode="layer" id="designTop" inkscape:label="Pattern Foreground"> +<path id="path1790" d="m 84.87396,19.36488 h -4.9936 v 0.31955 h 0.14957 c 0.67301,0 0.74773,0.0342 0.74773,0.31968 v 0.197 3.23589 0.19726 c 0,0.28537 -0.0747,0.31942 -0.74773,0.31942 h -0.14957 v 0.31955 h 5.10156 l 0.16619,-1.81515 h -0.36562 c -0.10782,0.47574 -0.29915,0.89731 -0.49844,1.09457 -0.25767,0.27186 -0.73125,0.40103 -1.42912,0.40103 h -0.54844 c -0.24928,0 -0.45696,-0.0407 -0.53181,-0.10201 -0.058,-0.0405 -0.0663,-0.0815 -0.0663,-0.22416 v -1.73354 h 0.16619 c 0.50668,0 0.71449,0.0407 0.88082,0.18336 0.21578,0.177 0.29901,0.39453 0.31563,0.79542 h 0.39048 v -2.22968 h -0.39048 c -0.0416,0.66626 -0.374,0.93136 -1.16335,0.93136 h -0.19929 v -1.55005 c 0,-0.29226 0.0748,-0.33995 0.52343,-0.33995 h 0.43197 c 0.73125,0 1.08849,0.0613 1.37115,0.25172 0.27415,0.17673 0.47345,0.55735 0.59816,1.16915 h 0.35738 L 84.874,19.36488 Z m -11.02598,2.72609 h 0.93892 c 0.74787,0 1.13835,-0.0476 1.47087,-0.17659 0.58978,-0.23132 0.92216,-0.66639 0.92216,-1.20334 0,-0.51642 -0.2909,-0.91095 -0.8392,-1.13525 -0.32401,-0.13579 -0.8392,-0.21091 -1.4125,-0.21091 h -2.90809 v 0.31955 h 0.14957 c 0.67301,0 0.74773,0.0342 0.74773,0.31968 v 0.197 3.23589 0.19726 c 0,0.28537 -0.0747,0.31942 -0.74773,0.31942 h -0.14957 v 0.31955 h 2.79176 v -0.31955 h -0.21619 c -0.67301,0 -0.74773,-0.034 -0.74773,-0.31942 V 23.437 Z m 0,-0.31941 v -1.74029 c 0,-0.31266 0.05,-0.34684 0.50696,-0.34684 h 0.53181 c 0.86407,0 1.27117,0.33319 1.27117,1.05376 0,0.70031 -0.42372,1.03337 -1.30441,1.03337 z m -7.22869,-2.50167 h -0.34886 l -1.91122,3.96308 c -0.16605,0.3536 -0.19929,0.40129 -0.32387,0.50993 -0.13309,0.12917 -0.36576,0.21078 -0.59018,0.21078 h -0.0331 v 0.31955 h 2.20185 v -0.31955 h -0.16633 c -0.44845,0 -0.67288,-0.12917 -0.67288,-0.38738 0,-0.0817 0.025,-0.17673 0.0747,-0.2855 l 0.27429,-0.59829 h 2.20184 l 0.44872,0.91095 c 0.0499,0.10201 0.0665,0.14944 0.0665,0.18362 0,0.10863 -0.20794,0.1766 -0.5152,0.1766 h -0.349 v 0.31955 h 2.57584 v -0.31955 h -0.11633 c -0.41562,0 -0.50695,-0.0543 -0.69801,-0.43494 L 66.6193,19.26989 Z m -0.4071,1.11484 0.93878,1.93067 H 65.28976 Z M 60.47896,19.31745 H 60.1632 l -0.33225,0.40116 C 59.24076,19.36488 58.91702,19.263 58.36021,19.263 c -0.80596,0 -1.47073,0.26523 -2.03565,0.81569 -0.53182,0.51669 -0.7811,1.08769 -0.7811,1.78799 0,1.46168 1.17145,2.50856 2.80851,2.50856 1.3294,0 2.17685,-0.6391 2.36804,-1.78123 l -0.39049,-0.0543 c -0.0831,0.36036 -0.18294,0.60491 -0.33252,0.80894 -0.34049,0.46912 -0.8723,0.70719 -1.54545,0.70719 -1.22969,0 -1.81122,-0.70043 -1.81122,-2.16185 0,-0.7684 0.12444,-1.28495 0.40696,-1.69286 0.25767,-0.38062 0.77273,-0.61869 1.30468,-0.61869 0.58154,0 1.09673,0.25158 1.4125,0.68679 0.15782,0.22429 0.28253,0.48939 0.47372,1.01283 h 0.36521 l -0.12444,-1.96459 z m -8.31718,0.007 h -0.30739 l -0.33238,0.40791 c -0.39062,-0.3059 -0.9223,-0.46912 -1.51222,-0.46912 -1.08849,0 -1.8196,0.571 -1.8196,1.42101 0,0.74084 0.44845,1.10795 1.6699,1.36629 l 0.78934,0.16322 c 0.61491,0.12904 0.67301,0.14268 0.84758,0.25159 0.24929,0.15619 0.38224,0.38048 0.38224,0.64572 0,0.27185 -0.12471,0.49614 -0.37386,0.6799 -0.27429,0.197 -0.5483,0.27185 -1.0054,0.27185 -0.61491,0 -1.05525,-0.15646 -1.44573,-0.50993 -0.34901,-0.31968 -0.52344,-0.63909 -0.64802,-1.16253 h -0.35738 l 0.0332,1.93756 h 0.32414 l 0.37373,-0.46237 c 0.55668,0.37387 1.02229,0.50993 1.74489,0.50993 1.22144,0 2.00254,-0.58451 2.00254,-1.49573 0,-0.42143 -0.17456,-0.78165 -0.49844,-1.03999 -0.22442,-0.17673 -0.54843,-0.29239 -1.21334,-0.42831 l -0.88906,-0.18349 c -0.73935,-0.15633 -1.08835,-0.42156 -1.08835,-0.83623 0,-0.47574 0.47358,-0.80232 1.17983,-0.80232 0.58167,0 1.05511,0.20416 1.3875,0.59154 0.24105,0.27874 0.39048,0.56424 0.49871,0.91095 h 0.35725 l -0.0997,-1.76745 z m -11.23365,2.72609 v -1.84919 -0.197 c 0,-0.2855 0.0746,-0.31968 0.74773,-0.31968 h 0.15795 v -0.31955 h -2.73366 v 0.31955 h 0.14957 c 0.67301,0 0.7476,0.0342 0.7476,0.31968 v 0.197 3.23589 0.19726 c 0,0.28537 -0.0746,0.31942 -0.7476,0.31942 h -0.14957 v 0.31955 h 2.73366 v -0.31955 h -0.15795 c -0.67315,0 -0.74773,-0.0341 -0.74773,-0.31942 v -0.19726 -0.86326 l 0.96378,-0.79542 1.44574,1.73353 c 0.13309,0.16308 0.16619,0.21754 0.16619,0.28563 0,0.10864 -0.15768,0.1562 -0.56492,0.1562 h -0.25766 v 0.31955 h 2.84161 v -0.31955 h -0.15781 c -0.45696,0 -0.57343,-0.0476 -0.81434,-0.33982 l -2.01066,-2.37263 1.23806,-1.01283 c 0.39873,-0.3467 0.90555,-0.54397 1.40413,-0.54397 v -0.31955 h -2.55923 v 0.31955 h 0.20794 c 0.38225,0 0.53993,0.0613 0.53993,0.20402 0,0.0951 -0.1662,0.29226 -0.40711,0.48939 z m -9.28947,-2.68542 h -1.71165 v 0.31955 h 0.20781 c 0.42372,0 0.61491,0.0544 0.76435,0.22456 v 2.88904 c 0,0.93136 -0.16619,1.12849 -0.96378,1.15565 v 0.31955 h 2.36817 v -0.31955 c -0.78962,-0.0272 -0.95567,-0.22429 -0.95567,-1.15565 V 20.2762 l 3.70595,4.09252 h 0.34887 v -3.52827 c 0,-0.93122 0.16606,-1.12849 0.96378,-1.15578 v -0.31955 h -2.36804 v 0.31955 c 0.78935,0.0273 0.95554,0.22456 0.95554,1.15578 V 22.975 Z m -5.40071,0.83623 v -0.197 c 0,-0.2855 0.0747,-0.31968 0.73935,-0.31968 h 0.16619 v -0.31955 h -2.75014 v 0.31955 h 0.16619 c 0.67301,0 0.74773,0.0342 0.74773,0.31968 v 0.197 3.23589 0.19726 c 0,0.28537 -0.0747,0.31942 -0.74773,0.31942 h -0.16619 v 0.31955 h 2.75014 V 23.95392 H 26.9773 c -0.66463,0 -0.73935,-0.0341 -0.73935,-0.31942 v -0.19726 z" style="fill:#000000;fill-opacity:1;stroke-width:1pt" inkscape:connector-curvature="0" /> +<g id="g7535" transform="matrix(1.314547,0,0,1.314547,-17.94833,-33.3228)"> +<path id="path2313" d="M 49.37627,75.52654 34.51809,90.7309 c -5.02019,6.2169 3.41648,5.49357 7.03314,7.28421 1.29735,1.32611 -4.97263,2.30489 -3.67528,3.63219 1.29735,1.3261 7.84495,2.5548 9.14451,3.881 1.29736,1.3261 -2.65553,2.7329 -1.35818,4.059 1.29735,1.3261 4.29797,0.07 4.85982,3.1311 0.40038,2.1877 5.4073,0.9402 7.85601,-0.8516 1.29736,-1.3272 -2.48189,-1.2022 -1.18454,-2.5283 3.22624,-3.2993 6.23017,-1.199 7.33397,-4.5048 0.54527,-1.6336 -4.74922,-2.5184 -3.44965,-3.8445 3.73279,-2.17998 16.63444,-3.59899 10.51265,-9.72077 L 56.18931,75.52654 c -1.88354,-1.80833 -5.02683,-1.82824 -6.81304,0 z m 17.06689,29.30716 c 0,0.7543 5.55771,1.2487 5.55771,-0.1781 -0.7919,-2.2917 -4.90074,-2.1368 -5.55771,0.1781 z m -25.03571,4.0082 c 1.31615,1.1381 3.34901,-0.2832 3.95842,-1.8714 -1.27523,-1.6944 -6.04879,0.061 -3.95842,1.8714 z m 24.33892,-2.4587 c -1.69662,1.5219 0.19023,3.0659 1.86253,2.0826 0.37272,-0.3782 -0.01,-1.7043 -1.86253,-2.0826 z" inkscape:connector-curvature="0" /> +<path style="fill:#ffffff" id="path2315" d="m 45.82044,98.83798 c 0.39706,0.24664 6.40271,1.46662 7.87039,1.70992 0.50876,0.1073 0.1482,0.6315 -0.55301,0.9854 -1.5816,0.4203 -9.2529,-2.69532 -7.31738,-2.69532 z" inkscape:connector-curvature="0" /> +<path style="fill:#ffffff" id="path2317" d="m 55.29123,76.59274 5.87846,5.97026 c 0.55743,0.5696 0.54969,1.6734 0.23779,1.99082 l -2.91877,-2.33479 -0.57402,3.4574 -2.43876,-1.2874 -3.90533,2.46751 -1.29293,-5.20158 -2.0981,3.62994 h -3.20744 c -1.30731,0 -1.46104,-1.65902 -0.27319,-2.84688 2.07488,-2.23968 4.45613,-4.52249 5.75016,-5.84528 1.30068,-1.32943 3.5669,-1.29182 4.84213,0 z" inkscape:connector-curvature="0" /> +</g> +<path id="path3959" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:100%;font-family:'Euphoria Script';-inkscape-font-specification:'Euphoria Script';letter-spacing:0px;word-spacing:0px;fill:#f58908;fill-opacity:1;stroke:none;stroke-width:2.2432382px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" d="m 109.8503,40.23567 q 2.3202,-1.13792 2.5606,-3.97352 0.186,-2.4898 -0.6114,-5.68054 -4.6175,2.38741 -5.4222,7.07206 -0.039,0.31176 -0.4521,0.31617 -0.2327,-0.0181 -0.2304,-0.20804 0.2868,-2.21912 1.6902,-4.37864 1.4161,-2.13367 4.2015,-3.62721 -0.3485,-1.42876 -0.9383,-3.28215 -0.589,-1.85376 -1.0504,-3.6417 l -0.2322,0.11386 q -0.4308,7.59868 -2.1838,8.45843 -1.9593,0.96092 -3.4388,-2.05579 -1.4792,-3.01595 -1.6821,-6.68994 -0.2158,-3.70067 0.7277,-4.45045 l 0.1545,-0.0758 q 0.4384,-0.21504 0.7184,0.35587 0.056,0.83196 0.1759,2.18389 0.1055,1.32413 0.6479,4.25553 0.5302,2.90629 1.2384,4.35032 0.6952,1.41738 1.314,1.11387 0.7217,-0.35392 1.0938,-3.63852 0.5507,-4.81127 0.4321,-9.42182 -0.024,-1.93929 0.8271,-2.3566 0.5412,-0.26544 0.8324,0.32831 -0.048,1.14247 0.4702,3.95838 0.518,2.81594 1.3185,5.5575 0.788,2.71564 1.1744,4.28536 2.1236,-0.62598 3.1031,0.58868 0.169,0.20985 0.3557,0.59046 0.2016,0.41105 0.031,0.84428 -0.156,0.46367 -0.3882,0.57753 -0.036,-0.20882 -0.2945,-0.65823 -0.2394,-0.43031 -0.5463,-0.65751 -0.2817,-0.24901 -0.8327,-0.39429 -0.5509,-0.14529 -1.2443,0.006 1.6818,8.45026 -3.2164,10.8525 -2.114,1.03679 -3.5436,-0.11763 -0.06,-0.0649 -0.086,-0.11821 -0.075,-0.15224 0.1831,-0.34478 0.2581,-0.12656 0.4763,-0.007 0.9829,0.8296 2.6841,-0.005 z m -5.8407,-2.47555 q -1.4953,0.73334 -2.9885,-0.4853 -1.46703,-1.23146 -3.00964,-4.37681 -1.54261,-3.14535 -2.72572,-7.9052 -1.18349,-4.76062 -1.33672,-8.20304 -0.12779,-3.45585 0.80028,-3.91101 0.43846,-0.21504 0.69233,0.30259 0.0658,1.50318 0.46712,4.40843 0.3887,2.87934 0.85833,5.27137 0.49552,2.37934 1.42237,5.4433 0.9522,3.05057 1.95085,5.08683 0.9864,2.01114 1.9039,2.90394 0.9566,0.90675 1.6525,0.56545 0.593,-0.29083 0.8543,-1.12726 0.2762,-0.8059 0.2422,-1.46251 -0.01,-0.34475 0.3897,-0.37998 0.1659,0.013 0.154,0.1794 0.036,0.20882 0.01,0.54268 0,0.3219 -0.098,1.0397 -0.1791,1.59116 -1.2361,2.10957 z M 88.98873,24.94693 q 1.9593,-0.96092 3.08453,1.33339 0.64474,1.31462 0.47641,3.18855 -0.31956,3.13037 -2.79443,4.34415 -0.3867,0.18965 -0.70822,0.1868 -0.32152,-0.003 -0.5771,-0.19857 1.83035,-0.89767 2.31467,-3.75757 0.40304,-2.30821 -0.29248,-3.72636 -0.51818,-1.05657 -1.36892,-0.63933 -1.70147,0.83447 -1.86875,4.21028 -0.15655,3.65857 1.33529,6.70039 1.26447,2.57825 2.98667,2.37291 0.3362,-0.0327 0.7739,-0.24735 0.43847,-0.21504 0.82728,-0.66069 0.37449,-0.47641 0.55987,-0.94505 0.36747,-0.94512 0.43843,-1.91007 0.002,-0.25593 0.2859,-0.39518 0.46434,-0.22773 0.51313,-0.0628 0.0605,0.31973 -0.12521,1.24463 -0.16169,0.9103 -0.39682,1.53838 -0.22218,0.59056 -0.76883,1.23639 -0.50561,0.66347 -1.20205,1.00503 -2.73269,1.34022 -4.74476,-0.87137 -0.66188,-0.7623 -1.11734,-1.69098 -0.84709,-1.72721 -1.04663,-4.15539 -0.25398,-3.71313 1.29294,-6.16685 0.85704,-1.31743 2.1202,-1.93693 z M 78.98146,29.8549 q 1.95922,-0.96088 3.08445,1.33343 0.64474,1.31462 0.47648,3.18851 -0.31963,3.13041 -2.7945,4.34419 -0.3867,0.18965 -0.70822,0.1868 -0.32152,-0.003 -0.5771,-0.19857 1.83035,-0.89767 2.31467,-3.75757 0.40304,-2.30821 -0.29248,-3.72636 -0.51818,-1.05657 -1.36892,-0.63933 -1.70148,0.83447 -1.86875,4.21028 -0.15655,3.65857 1.33529,6.70039 1.26447,2.57825 2.98667,2.37291 0.3362,-0.0327 0.7739,-0.24735 0.43846,-0.21504 0.82728,-0.66069 0.37449,-0.47641 0.55987,-0.94505 0.36747,-0.94512 0.43843,-1.91007 0.002,-0.25593 0.2859,-0.39518 0.46434,-0.22773 0.51312,-0.0628 0.0605,0.31973 -0.1252,1.24463 -0.16169,0.9103 -0.39682,1.53838 -0.22219,0.59056 -0.76883,1.23639 -0.50561,0.66347 -1.20205,1.00503 -2.73269,1.34022 -4.74476,-0.87137 -0.66188,-0.7623 -1.11734,-1.69098 -0.84709,-1.72721 -1.04656,-4.15543 -0.25405,-3.71309 1.29294,-6.16685 0.85697,-1.31739 2.12021,-1.93693 z m -5.99756,9.27308 q -0.97961,0.48044 -2.02905,-1.65934 -0.59397,-1.2111 -0.64818,-2.49616 -1.00717,2.38069 -1.1369,7.59367 -0.1428,5.18633 0.47693,6.44995 0.15307,0.3121 -0.25951,0.51445 -0.74752,0.36661 -1.74656,-1.67041 -1.88383,-3.8411 -2.64035,-7.33988 -0.75614,-3.49801 0.35242,-4.0417 0.49022,-0.24042 0.77022,0.33049 0.65986,4.34508 2.07889,8.54256 l 0.18041,-0.0885 q -0.27614,-5.84491 0.9227,-9.79086 0.68511,-2.25485 1.87094,-2.83643 0.25805,-0.12656 0.48724,-0.0501 0.25508,0.0638 0.37081,0.29974 -0.0908,0.27117 -0.17339,0.7555 -0.0826,0.48434 0.15133,2.06843 0.21898,1.55555 1.0026,3.15334 0.1008,0.20553 -0.0278,0.26863 z m -24.00261,4.57617 q 0.93557,1.90762 2.08179,1.50599 0.0978,0.39586 -0.41752,0.6486 -1.05703,0.51841 -2.12769,-0.55616 -0.49748,-0.49258 -0.91412,-1.3421 -0.43008,-0.87692 -0.35418,-2.41655 0.14265,-3.55637 3.74658,-6.31542 1.23938,-0.92891 2.78618,-1.68752 1.5726,-0.77127 2.52802,-1.62701 0.95549,-0.85579 1.18133,-1.4387 0.58996,-1.53584 1.10553,-1.7887 0.51534,-0.25274 0.66841,0.0594 0.0373,0.0761 0.0747,0.15224 0.17425,0.81164 -0.87704,2.12424 -0.64947,0.76235 -1.57615,1.48124 -0.67528,0.77501 -0.44428,2.68066 0.2169,1.87669 1.09001,5.22196 1.27704,-0.78684 2.15358,-1.21673 0.23217,-0.11387 0.34443,0.18048 0.0503,0.36249 -0.37696,0.60037 -0.43847,0.21504 -1.90971,1.25766 1.72164,6.57513 2.03307,9.49236 0.80387,7.37746 -3.39828,9.43837 -3.01625,1.47929 -5.1168,-0.91272 -0.75172,-0.81455 -1.21951,-1.76836 -0.88479,-1.80408 -0.81608,-4.07675 0.0907,-3.46668 2.43669,-4.61725 0.33494,-0.16427 0.61589,-0.1132 0.30684,0.0384 0.53679,0.31277 -2.21705,1.08733 -2.53547,4.08967 -0.26189,2.3353 0.67368,4.24291 1.36564,2.78454 3.62846,2.44249 0.52781,-0.0983 1.2751,-0.46483 0.74752,-0.36661 1.35607,-1.21277 0.64913,-0.82829 0.76238,-2.29275 0.1518,-1.45032 0.22381,-2.41295 0.0592,-0.98843 -0.33485,-3.22587 -0.50499,-2.72598 -1.04037,-4.99039 -0.54701,-2.28988 -0.64659,-2.75286 -1.33165,0.93639 -2.07925,1.30304 -0.72163,0.35392 -1.14234,-0.24241 -0.2767,-0.50643 -0.007,-0.73301 0.20331,0.0891 0.87387,-0.23971 0.69575,-0.34123 2.10204,-1.19147 -0.59433,-2.84269 -0.77295,-4.70604 -0.19101,-1.88939 0.2038,-3.10571 -0.41258,0.20235 -1.28905,0.6322 -4.94974,2.42755 -5.50603,6.31427 -0.28375,1.83421 0.3987,3.22572 z m 13.93518,-0.27799 q 0.0635,0.1294 -0.1687,0.24327 -0.23218,0.11386 -0.51288,0.12877 -0.25856,-0.005 -0.34442,-0.18047 -1.28949,-2.62925 -1.4805,-4.51863 -0.2037,-1.91527 0.77591,-2.39571 0.25805,-0.12656 0.52806,-0.0324 0.27001,0.0942 0.41934,0.3987 -0.59114,1.72906 0.0184,4.27626 0.26186,1.05574 0.76736,2.08643 z m -26.85252,8.49992 q 1.02752,0.2043 1.69785,-0.12446 0.69575,-0.34122 0.89009,-0.66317 0.16426,0.33494 0.008,0.79861 -0.1458,0.4209 -0.7126,0.69889 -0.54123,0.26544 -1.31284,0.3228 1.13504,2.44909 1.6409,5.36728 0.49157,2.89309 0.15269,5.20195 -0.35143,2.2829 -1.51153,2.85186 -1.16009,0.56895 -2.22121,-0.0297 -1.13792,-0.68935 -2.04848,-2.54596 -0.51818,-1.05657 -0.98388,-2.33152 -0.38965,7.2914 -2.11693,8.13853 -1.70148,0.83447 -3.1179,-2.05359 -1.46645,-2.99006 -1.66579,-7.11339 -0.0901,-3.31378 0.87762,-3.94894 0.49023,-0.24042 0.75529,0.30004 0.0568,0.89757 0.17487,2.3128 0.10462,1.38783 0.596,4.34523 0.51696,2.94486 1.12362,4.18184 0.59435,1.21185 1.13557,0.94642 0.67064,-0.32891 1.02605,-3.18979 0.38152,-2.87369 0.40214,-5.57039 l 0.0595,-2.6827 q 0.0134,-1.79795 0.58076,-2.0762 0.56711,-0.27813 0.83217,0.26234 1.06992,6.15913 2.56176,9.20095 0.69552,1.41815 1.52045,1.01357 0.92808,-0.45516 1.18758,-2.46917 0.27261,-2.05255 -0.25815,-4.83011 -0.51832,-2.81671 -1.69395,-5.21378 l -0.0747,-0.15224 q -1.01258,-0.17386 -1.84406,-0.69527 -0.83021,-0.51827 -1.00791,-0.88061 -0.1904,-0.38822 -0.005,-0.85697 0.18187,-0.47636 0.56857,-0.66602 0.48946,-0.24005 1.30654,0.44707 0.80372,0.66063 1.47631,1.70663 z M 17.6483,75.44555 q -2.11398,1.03678 -3.74507,-2.28898 -0.97365,-1.98526 -1.15689,-4.83693 -0.26478,-3.99586 1.35792,-6.29505 0.70002,-0.98545 1.52495,-1.39003 0.82501,-0.40461 1.46451,-0.27442 0.66569,0.11734 0.97354,0.41963 l 0.31879,0.25915 q 0.13889,0.47959 -0.22193,0.65655 -0.41258,0.20234 -0.57982,0.0577 -0.15409,-0.17939 -0.29291,-0.27184 -0.15231,-0.11416 -0.55122,-0.21126 -0.41087,-0.11956 -0.77168,0.0574 -1.67575,0.82185 -1.56254,4.50865 0.16007,4.2389 1.6646,7.30661 0.75861,1.54679 1.37748,1.24327 0.49023,-0.24042 0.83544,-1.75254 0.3584,-1.55165 0.529,-3.68165 0.31044,-3.67077 0.34334,-6.27716 -0.0336,-2.28574 0.89444,-2.74091 0.48946,-0.24005 0.78066,0.3537 0.007,0.60105 0.0898,1.68309 0.0816,1.07901 0.80339,4.05088 0.72189,2.97183 2.02445,5.62772 1.30218,2.65513 2.10138,2.26317 0.30906,-0.15157 0.42898,-0.55978 0.13112,-0.38538 0.0723,-1.02701 -0.0605,-0.31973 0.22269,-0.45861 0.10276,-0.0504 0.19186,3.3e-4 0.0906,0.05 0.12693,0.25882 0.0363,0.20882 0.0585,0.57566 0.0356,0.39802 -0.1374,1.15429 -0.14751,0.74281 -0.61148,0.97036 -1.08275,0.53102 -2.37081,-0.59558 -1.26253,-1.13998 -2.2108,-3.07348 -0.94826,-1.93349 -1.5368,-3.85171 l -0.25806,0.12656 q -0.53045,7.19993 -2.18032,8.00909 z M 10.10761,69.96506 Q 9.127997,70.4455 8.078561,68.30572 7.484589,67.09462 7.430374,65.80956 q -1.007167,2.38069 -1.1369,7.59367 -0.142799,5.18633 0.476932,6.44996 0.153066,0.3121 -0.259514,0.51444 -0.747516,0.36661 -1.746553,-1.67041 -1.883833,-3.8411 -2.640351,-7.33988 -0.756144,-3.49801 0.352417,-4.0417 0.490225,-0.24042 0.770224,0.33049 0.659852,4.34508 2.078886,8.54257 l 0.180409,-0.0885 q -0.276139,-5.84492 0.922698,-9.79086 0.685115,-2.25486 1.87094,-2.83644 0.258053,-0.12656 0.487247,-0.0501 0.255075,0.0638 0.370808,0.29974 -0.09081,0.27117 -0.173396,0.75551 -0.08259,0.48433 0.151337,2.06842 0.218977,1.55555 1.002602,3.15335 0.1008,0.20552 -0.0278,0.26862 z m -28.80073,8.01722 q -0.95389,0.46782 -1.61132,-0.87268 -0.65744,-1.34051 -0.0747,-3.67358 0.95492,-3.92169 4.86469,-6.38313 l 1.38051,-0.77149 q 4.691995,-2.30114 8.638958,0.3997 2.388837,1.67552 3.855286,4.66559 0.607038,1.23774 1.0708788,2.7053 1.50293,4.95523 0.2604394,9.52978 -1.3613282,5.04927 -5.4861402,7.07224 -4.099006,2.01032 -6.332712,0.25966 -0.6896,-0.55889 -1.08086,-1.35665 -0.40469,-0.82516 -0.40862,-1.94224 0.0414,-2.06756 1.5108,-2.78824 0.12865,-0.0631 0.2292,0.0765 0.11675,0.10327 0.11529,0.29285 0.0214,0.17838 -0.10574,0.24072 -0.87654,0.4299 -0.96443,1.88097 -0.021,1.00087 0.30795,1.6715 0.32854,0.66987 0.8651,1.11118 1.684414,1.3477 4.803733,-0.18214 3.531898,-1.73218 4.623501,-6.74455 0.984933,-4.51244 -0.416672,-9.26146 -0.437465,-1.54471 -1.057196,-2.80833 -1.377969,-2.80965 -3.589474,-4.1236 -2.952842,-1.78231 -6.536272,-0.0249 -4.4857,2.19997 -5.24904,6.31666 -0.37568,2.1031 0.28176,3.4436 0.26506,0.54047 0.49723,0.4266 0.0993,0.59342 -0.39088,0.83384 z m 8.50402,7.94956 q -1.92191,-3.91875 -3.03383,-7.94579 -1.12499,-4.05368 -1.16871,-6.68671 -0.031,-2.67138 0.9229,-3.13921 0.41258,-0.20234 0.61418,0.20871 0.0159,2.9668 1.09898,7.39232 1.95388,8.09206 3.547261,11.34094 0.164266,0.33493 -0.196551,0.51189 Q -9.178267,87.9933 -10.19,85.9304 Z" inkscape:connector-curvature="0" /> +</g> +<g id="designBottomGenerator" sodipodi:insensitive="true"> +<use height="100%" width="100%" id="bottom1" transform="translate(-100,-100)" xlink:href="#designBottom" y="0" x="0" /> +<use height="100%" width="100%" id="bottom2" transform="translate(0,-100)" xlink:href="#designBottom" y="0" x="0" /> +<use height="100%" width="100%" id="bottom3" transform="translate(100,-100)" xlink:href="#designBottom" y="0" x="0" /> +<use height="100%" width="100%" id="bottom4" transform="translate(-100)" xlink:href="#designBottom" y="0" x="0" /> +<use height="100%" width="100%" id="bottom5" xlink:href="#designBottom" y="0" x="0" /> +<use height="100%" width="100%" id="bottom6" transform="translate(100)" xlink:href="#designBottom" y="0" x="0" /> +<use height="100%" width="100%" id="bottom7" transform="translate(-100,100)" xlink:href="#designBottom" y="0" x="0" /> +<use height="100%" width="100%" id="bottom8" transform="translate(0,100)" xlink:href="#designBottom" y="0" x="0" /> +<use transform="translate(100,100)" height="100%" width="100%" id="bottom9" xlink:href="#designBottom" y="0" x="0" /> +</g> +<g id="designTopGenerator" sodipodi:insensitive="true"> +<use height="100%" width="100%" id="top1" transform="translate(-100,-100)" xlink:href="#designTop" y="0" x="0" /> +<use height="100%" width="100%" id="top2" transform="translate(0,-100)" xlink:href="#designTop" y="0" x="0" /> +<use height="100%" width="100%" id="top3" transform="translate(100,-100)" xlink:href="#designTop" y="0" x="0" /> +<use height="100%" width="100%" id="top4" transform="translate(-100)" xlink:href="#designTop" y="0" x="0" /> +<use height="100%" width="100%" id="top5" xlink:href="#designTop" y="0" x="0" /> +<use height="100%" width="100%" id="top6" transform="translate(100)" xlink:href="#designTop" y="0" x="0" /> +<use height="100%" width="100%" id="top7" transform="translate(-100,100)" xlink:href="#designTop" y="0" x="0" /> +<use height="100%" width="100%" id="top8" transform="translate(0,100)" xlink:href="#designTop" y="0" x="0" /> +<use transform="translate(100,100)" height="100%" width="100%" id="top9" xlink:href="#designTop" y="0" x="0" /> +</g> +</g> +</g> +<inkscape:_templateinfo id="_templateinfo10"> +<inkscape:_name id="_name12">Seamless Pattern</inkscape:_name> +<inkscape:_shortdesc id="_shortdesc14">Seamless Pattern</inkscape:_shortdesc> +<inkscape:_keywords id="_keywords16">Seamless Pattern</inkscape:_keywords> +</inkscape:_templateinfo> </svg> diff --git a/share/extensions/simplepath.py b/share/extensions/simplepath.py index 94ab09242..514dd4666 100755..100644 --- a/share/extensions/simplepath.py +++ b/share/extensions/simplepath.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python """ simplepath.py functions for digesting paths into a simple list structure diff --git a/share/extensions/simplestyle.py b/share/extensions/simplestyle.py index 806b81813..ca33e68a4 100644 --- a/share/extensions/simplestyle.py +++ b/share/extensions/simplestyle.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python """ simplestyle.py Two simple functions for working with inline css diff --git a/share/extensions/simpletransform.py b/share/extensions/simpletransform.py index 47cc61ec8..8b6f46935 100755..100644 --- a/share/extensions/simpletransform.py +++ b/share/extensions/simpletransform.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python ''' Copyright (C) 2006 Jean-Francois Barraud, barraud@math.univ-lille1.fr Copyright (C) 2010 Alvin Penner, penner@vaxxine.com @@ -79,6 +78,21 @@ def parseTransform(transf,mat=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]): def formatTransform(mat): return ("matrix(%f,%f,%f,%f,%f,%f)" % (mat[0][0], mat[1][0], mat[0][1], mat[1][1], mat[0][2], mat[1][2])) +def invertTransform(mat): + det = mat[0][0]*mat[1][1] - mat[0][1]*mat[1][0] + if det !=0: # det is 0 only in case of 0 scaling + # invert the rotation/scaling part + a11 = mat[1][1]/det + a12 = -mat[0][1]/det + a21 = -mat[1][0]/det + a22 = mat[0][0]/det + # invert the translational part + a13 = -(a11*mat[0][2] + a12*mat[1][2]) + a23 = -(a21*mat[0][2] + a22*mat[1][2]) + return [[a11,a12,a13],[a21,a22,a23]] + else: + return[[0,0,-mat[0][2]],[0,0,-mat[1][2]]] + def composeTransform(M1,M2): a11 = M1[0][0]*M2[0][0] + M1[0][1]*M2[1][0] a12 = M1[0][0]*M2[0][1] + M1[0][1]*M2[1][1] @@ -238,4 +252,10 @@ def computeBBox(aList,mat=[[1,0,0],[0,1,0]]): return bbox +def computePointInNode(pt, node, mat=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]): + if node.getparent() is not None: + applyTransformToPoint(invertTransform(composeParents(node, mat)), pt) + return pt + + # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/sk2svg.sh b/share/extensions/sk2svg.sh index dbfb3d1f7..886e92e58 100755 --- a/share/extensions/sk2svg.sh +++ b/share/extensions/sk2svg.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh rc=0 diff --git a/share/extensions/spirograph.py b/share/extensions/spirograph.py index 77a258d5f..e702344a5 100755 --- a/share/extensions/spirograph.py +++ b/share/extensions/spirograph.py @@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' import inkex, simplestyle, math +from simpletransform import computePointInNode class Spirograph(inkex.Effect): def __init__(self): @@ -81,12 +82,13 @@ class Spirograph(inkex.Effect): theta = i * scale + view_center = computePointInNode(list(self.view_center), self.current_layer) x = a * math.cos(theta + rotation) + \ self.options.penr * math.cos(ratio * theta + rotation) * flip + \ - self.view_center[0] + view_center[0] y = a * math.sin(theta + rotation) - \ self.options.penr * math.sin(ratio * theta + rotation) + \ - self.view_center[1] + view_center[1] dx = (-a * math.sin(theta + rotation) - \ ratio * self.options.penr * math.sin(ratio * theta + rotation) * flip) * scale / 3 diff --git a/share/extensions/summersnight.py b/share/extensions/summersnight.py index 67413a05c..fbf88fe92 100755 --- a/share/extensions/summersnight.py +++ b/share/extensions/summersnight.py @@ -24,7 +24,6 @@ import cubicsuperpath import inkex import simplepath import simpletransform -import voronoi2svg from ffgeom import * inkex.localize() @@ -115,7 +114,7 @@ class Project(inkex.Effect): csp[0] = self.trafopoint(csp[0]) csp[1] = self.trafopoint(csp[1]) csp[2] = self.trafopoint(csp[2]) - mat = voronoi2svg.Voronoi2svg().invertTransform(mat) + mat = simpletransform.invertTransform(mat) simpletransform.applyTransformToPath(mat, p) path.set('d',cubicsuperpath.formatPath(p)) diff --git a/share/extensions/svg2fxg.inx b/share/extensions/svg2fxg.inx index e2f9761fc..e2f9761fc 100755..100644 --- a/share/extensions/svg2fxg.inx +++ b/share/extensions/svg2fxg.inx diff --git a/share/extensions/svg2fxg.xsl b/share/extensions/svg2fxg.xsl index 3853b4d7b..3853b4d7b 100755..100644 --- a/share/extensions/svg2fxg.xsl +++ b/share/extensions/svg2fxg.xsl diff --git a/share/extensions/svg2xaml.xsl b/share/extensions/svg2xaml.xsl index c384b022f..abc519065 100755..100644 --- a/share/extensions/svg2xaml.xsl +++ b/share/extensions/svg2xaml.xsl @@ -2385,7 +2385,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt inkscape"> </xsl:choose> </xsl:variable> <xsl:if test="$top_val != '' and $size_val != ''"> - <xsl:value-of select="$top_val - $size_val" /> + <xsl:value-of select='format-number($top_val - $size_val, "#.#")' /> </xsl:if> </xsl:attribute> </xsl:if> diff --git a/share/extensions/text_extract.py b/share/extensions/text_extract.py index dfcddefdc..b6b575dfc 100755 --- a/share/extensions/text_extract.py +++ b/share/extensions/text_extract.py @@ -163,4 +163,4 @@ if __name__ == '__main__': e = Extract() e.affect() -# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99 +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/text_merge.py b/share/extensions/text_merge.py index 625f14b75..a3ba29022 100644..100755 --- a/share/extensions/text_merge.py +++ b/share/extensions/text_merge.py @@ -199,4 +199,4 @@ if __name__ == '__main__': e = Merge() e.affect() -# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99 +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/triangle.py b/share/extensions/triangle.py index 019db3147..ecd977d40 100755 --- a/share/extensions/triangle.py +++ b/share/extensions/triangle.py @@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import inkex import simplestyle, sys +from simpletransform import computePointInNode from math import * def draw_SVG_tri( (x1, y1), (x2, y2), (x3, y3), (ox,oy), width, name, parent): @@ -121,7 +122,7 @@ class Grid_Polar(inkex.Effect): def effect(self): tri = self.current_layer - offset = (self.view_center[0],self.view_center[1]) #the offset require to centre the triangle + offset = computePointInNode(list(self.view_center), self.current_layer) #the offset require to centre the triangle self.options.s_a = self.unittouu(str(self.options.s_a) + 'px') self.options.s_b = self.unittouu(str(self.options.s_b) + 'px') self.options.s_c = self.unittouu(str(self.options.s_c) + 'px') diff --git a/share/extensions/voronoi2svg.py b/share/extensions/voronoi2svg.py index 289c352e3..26a89393c 100755 --- a/share/extensions/voronoi2svg.py +++ b/share/extensions/voronoi2svg.py @@ -171,23 +171,6 @@ class Voronoi2svg(inkex.Effect): #{{{ Transformation helpers - def invertTransform(self,mat): - det = mat[0][0]*mat[1][1] - mat[0][1]*mat[1][0] - if det !=0: #det is 0 only in case of 0 scaling - #invert the rotation/scaling part - a11 = mat[1][1]/det - a12 = -mat[0][1]/det - a21 = -mat[1][0]/det - a22 = mat[0][0]/det - - #invert the translational part - a13 = -(a11*mat[0][2] + a12*mat[1][2]) - a23 = -(a21*mat[0][2] + a22*mat[1][2]) - - return [[a11,a12,a13],[a21,a22,a23]] - else: - return[[0,0,-mat[0][2]],[0,0,-mat[1][2]]] - def getGlobalTransform(self,node): parent = node.getparent() myTrans = simpletransform.parseTransform(node.get('transform')) @@ -239,7 +222,7 @@ class Voronoi2svg(inkex.Effect): trans = self.getGlobalTransform(parentGroup) invtrans = None if trans: - invtrans = self.invertTransform(trans) + invtrans = simpletransform.invertTransform(trans) #}}} diff --git a/share/extensions/whirl.py b/share/extensions/whirl.py index cea9da8df..7ee9cc0a2 100755 --- a/share/extensions/whirl.py +++ b/share/extensions/whirl.py @@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' import math, inkex, cubicsuperpath +from simpletransform import computePointInNode class Whirl(inkex.Effect): def __init__(self): @@ -30,6 +31,7 @@ class Whirl(inkex.Effect): dest="rotation", default=True, help="direction of rotation") def effect(self): + view_center = computePointInNode(list(self.view_center), self.current_layer) for id, node in self.selected.iteritems(): rotation = -1 if self.options.rotation == True: @@ -41,16 +43,16 @@ class Whirl(inkex.Effect): for sub in p: for csp in sub: for point in csp: - point[0] -= self.view_center[0] - point[1] -= self.view_center[1] + point[0] -= view_center[0] + point[1] -= view_center[1] dist = math.sqrt((point[0] ** 2) + (point[1] ** 2)) if dist != 0: a = rotation * dist * whirl theta = math.atan2(point[1], point[0]) + a point[0] = (dist * math.cos(theta)) point[1] = (dist * math.sin(theta)) - point[0] += self.view_center[0] - point[1] += self.view_center[1] + point[0] += view_center[0] + point[1] += view_center[1] node.set('d',cubicsuperpath.formatPath(p)) if __name__ == '__main__': diff --git a/share/extensions/wireframe_sphere.py b/share/extensions/wireframe_sphere.py index bcd676dc4..bda06af21 100755 --- a/share/extensions/wireframe_sphere.py +++ b/share/extensions/wireframe_sphere.py @@ -59,6 +59,7 @@ from math import * # local library import inkex import simplestyle +from simpletransform import computePointInNode inkex.localize() @@ -129,7 +130,7 @@ class Wireframe_Sphere(inkex.Effect): #INKSCAPE GROUP TO CONTAIN EVERYTHING - centre = self.view_center #Put in in the centre of the current view + centre = tuple(computePointInNode(list(self.view_center), self.current_layer)) #Put in in the centre of the current view grp_transform = 'translate' + str( centre ) + flip grp_name = 'WireframeSphere' grp_attribs = {inkex.addNS('label','inkscape'):grp_name, |
