diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-02-19 10:48:41 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-02-19 10:48:41 +0000 |
| commit | f15ac06ffd9cc8dbb098b18a6b273b32fc904fc9 (patch) | |
| tree | 482bc967d7e637d3f8817aa2074362a461465603 /share | |
| parent | update to trunk (diff) | |
| parent | Add SVG2 property 'paint-order'. (diff) | |
| download | inkscape-f15ac06ffd9cc8dbb098b18a6b273b32fc904fc9.tar.gz inkscape-f15ac06ffd9cc8dbb098b18a6b273b32fc904fc9.zip | |
update to trunk
(bzr r11950.1.254)
Diffstat (limited to 'share')
| -rw-r--r-- | share/attributes/css_defaults | 2 | ||||
| -rw-r--r-- | share/attributes/cssprops | 2 | ||||
| -rwxr-xr-x | share/attributes/genMapDataCSS.pl | 6 | ||||
| -rwxr-xr-x | share/extensions/dimension.py | 21 | ||||
| -rwxr-xr-x | share/extensions/dots.py | 2 | ||||
| -rw-r--r-- | share/extensions/hpgl_encoder.py | 101 | ||||
| -rwxr-xr-x | share/extensions/ink2canvas.py | 2 | ||||
| -rw-r--r-- | share/extensions/ink2canvas/canvas.py | 5 | ||||
| -rwxr-xr-x | share/extensions/inkex.py | 7 | ||||
| -rwxr-xr-x | share/extensions/interp.py | 14 | ||||
| -rwxr-xr-x | share/extensions/measure.py | 5 | ||||
| -rwxr-xr-x | share/extensions/perspective.py | 5 | ||||
| -rw-r--r-- | share/extensions/plotter.inx | 2 | ||||
| -rw-r--r-- | share/extensions/plotter.py | 20 | ||||
| -rwxr-xr-x | share/extensions/printing_marks.py | 17 | ||||
| -rw-r--r-- | share/extensions/render_gears.py | 4 | ||||
| -rwxr-xr-x | share/extensions/summersnight.py | 5 | ||||
| -rwxr-xr-x | share/extensions/voronoi2svg.py | 12 | ||||
| -rwxr-xr-x | share/extensions/webslicer_create_rect.py | 9 | ||||
| -rw-r--r-- | share/filters/filters.svg | 27 |
20 files changed, 132 insertions, 136 deletions
diff --git a/share/attributes/css_defaults b/share/attributes/css_defaults index e001c091b..5675c6a3b 100644 --- a/share/attributes/css_defaults +++ b/share/attributes/css_defaults @@ -88,6 +88,8 @@ "overflow" - "hidden" - "no" +"paint-order" - "normal" - "yes" + "pointer-events" - "visiblePainted" - "yes" "shape-rendering" - "auto" - "yes" diff --git a/share/attributes/cssprops b/share/attributes/cssprops index 42244f643..a4bc8a398 100644 --- a/share/attributes/cssprops +++ b/share/attributes/cssprops @@ -88,6 +88,8 @@ "overflow" - "svg","symbol","foreignObject","pattern","marker" +"paint-order" - "a","defs","glyph","g","marker","mask","missing-glyph","pattern","svg","switch","symbol","use","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","a","defs","glyph","g","marker","mask","missing-glyph","pattern","svg","switch","symbol","use" + "pointer-events" - "circle","ellipse","image","line","path","polygon","polyline","rect","text","use","a","defs","glyph","g","marker","mask","missing-glyph","pattern","svg","switch","symbol","use" "shape-rendering" - "path","rect","circle","ellipse","line","polyline","polygon","a","defs","glyph","g","marker","mask","missing-glyph","pattern","svg","switch","symbol","use" diff --git a/share/attributes/genMapDataCSS.pl b/share/attributes/genMapDataCSS.pl index 98994350a..4a32f96c7 100755 --- a/share/attributes/genMapDataCSS.pl +++ b/share/attributes/genMapDataCSS.pl @@ -194,6 +194,12 @@ push @{$properties{ "isolation" }->{elements}}, @graphics_elements; $properties{ "isolation" }->{default} = "auto"; $properties{ "isolation" }->{inherit} = "no"; +# SVG2 +push @{$properties{ "paint-order" }->{elements}}, @container_elements; +push @{$properties{ "paint-order" }->{elements}}, @graphics_elements; +$properties{ "paint-order" }->{default} = "normal"; +$properties{ "paint-order" }->{inherit} = "yes"; + # Output diff --git a/share/extensions/dimension.py b/share/extensions/dimension.py index 4285effeb..30b674201 100755 --- a/share/extensions/dimension.py +++ b/share/extensions/dimension.py @@ -100,8 +100,9 @@ class Dimension(pathmodifier.PathModifier): return line def effect(self): - self.xoffset = self.options.xoffset - self.yoffset = self.options.yoffset + scale = self.unittouu('1px') # convert to document units + self.xoffset = scale*self.options.xoffset + self.yoffset = scale*self.options.yoffset # query inkscape about the bounding box if len(self.options.ids) == 0: @@ -117,11 +118,11 @@ class Dimension(pathmodifier.PathModifier): if bsubprocess: p = Popen('inkscape --query-%s --query-id=%s "%s"' % (query,id,file), shell=True, stdout=PIPE, stderr=PIPE) rc = p.wait() - q[query] = float(p.stdout.read()) + q[query] = scale*float(p.stdout.read()) err = p.stderr.read() else: f,err = os.popen3('inkscape --query-%s --query-id=%s "%s"' % (query,id,file))[1:] - q[query] = float(f.read()) + q[query] = scale*float(f.read()) f.close() err.close() self.bbox = (q['x'], q['x']+q['width'], q['y'], q['y']+q['height']) @@ -146,29 +147,29 @@ class Dimension(pathmodifier.PathModifier): line = self.dimHLine(self.bbox[2], [0, 1]) line.set('marker-start', 'url(#Arrow1Lstart)') line.set('marker-end', 'url(#Arrow1Lend)') - line.set('stroke-width', '1') + line.set('stroke-width', str(scale)) group.append(line) line = self.dimVLine(self.bbox[0], [0, 2]) - line.set('stroke-width', '0.5') + line.set('stroke-width', str(0.5*scale)) group.append(line) line = self.dimVLine(self.bbox[1], [0, 2]) - line.set('stroke-width', '0.5') + line.set('stroke-width', str(0.5*scale)) group.append(line) line = self.dimVLine(self.bbox[0], [1, 0]) line.set('marker-start', 'url(#Arrow1Lstart)') line.set('marker-end', 'url(#Arrow1Lend)') - line.set('stroke-width', '1') + line.set('stroke-width', str(scale)) group.append(line) line = self.dimHLine(self.bbox[2], [2, 0]) - line.set('stroke-width', '0.5') + line.set('stroke-width', str(0.5*scale)) group.append(line) line = self.dimHLine(self.bbox[3], [2, 0]) - line.set('stroke-width', '0.5') + line.set('stroke-width', str(0.5*scale)) group.append(line) for id, node in self.selected.iteritems(): diff --git a/share/extensions/dots.py b/share/extensions/dots.py index 33ead21e7..dc533ffb6 100755 --- a/share/extensions/dots.py +++ b/share/extensions/dots.py @@ -112,7 +112,7 @@ class Dots(inkex.Effect): def addText(self,node,x,y,text): new = inkex.etree.SubElement(node,inkex.addNS('text','svg')) - s = {'font-size': self.options.fontsize, 'fill-opacity': '1.0', 'stroke': 'none', + s = {'font-size': self.unittouu(self.options.fontsize), 'fill-opacity': '1.0', 'stroke': 'none', 'font-weight': 'normal', 'font-style': 'normal', 'fill': '#999'} new.set('style', simplestyle.formatStyle(s)) new.set('x', str(x)) diff --git a/share/extensions/hpgl_encoder.py b/share/extensions/hpgl_encoder.py index 2304ce261..42c3bb821 100644 --- a/share/extensions/hpgl_encoder.py +++ b/share/extensions/hpgl_encoder.py @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import math import re import string +#from StringIO import StringIO # local libraries import bezmisc import cspsubdiv @@ -36,11 +37,6 @@ import simpletransform class hpglEncoder: PI = math.pi TWO_PI = PI * 2 - # a dictionary of arbitrary unit to user unit conversion factors - # in = Inch; pt = PostScript Point; px = Pixel; mm = Millimeter; cm = Centimeter; - # km = Kilometer; pc = PostScript Pica; yd = Yard; ft = Feet; m = Meter - __USER_UNIT_CONVERSION = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, - 'km':3543307.0866, 'pc':15.0, 'yd':3240 , 'ft':1080, 'm':3543.3070866} def __init__(self, effect): ''' options: @@ -66,26 +62,21 @@ class hpglEncoder: ''' self.options = effect.options self.doc = effect.document.getroot() - self.documentUnit = self.doc.xpath('//sodipodi:namedview/@inkscape:document-units', namespaces=inkex.NSS) - if self.documentUnit: - self.documentUnit = self.documentUnit[0] - else: - self.documentUnit = 'px' - self.docWidth = self.unitToUserUnit(self.doc.get('width'), True) - self.docHeight = self.unitToUserUnit(self.doc.get('height'), True) + self.docWidth = effect.unittouu(self.doc.get('width')) + self.docHeight = effect.unittouu(self.doc.get('height')) self.divergenceX = 'False' self.divergenceY = 'False' self.sizeX = 'False' self.sizeY = 'False' self.dryRun = True self.lastPoint = [0, 0, 0] - self.scaleX = self.options.resolutionX / self.unitToUserUnit("1.0in") # dots per inch to dots per user unit - self.scaleY = self.options.resolutionY / self.unitToUserUnit("1.0in") # dots per inch to dots per user unit + self.scaleX = self.options.resolutionX / effect.unittouu("1.0in") # dots per inch to dots per user unit + self.scaleY = self.options.resolutionY / effect.unittouu("1.0in") # dots per inch to dots per user unit scaleXY = (self.scaleX + self.scaleY) / 2 - self.offsetX = self.unitToUserUnit(str(self.options.offsetX) + "mm") * self.scaleX # mm to dots (plotter coordinate system) - self.offsetY = self.unitToUserUnit(str(self.options.offsetY) + "mm") * self.scaleY # mm to dots - self.overcut = self.unitToUserUnit(str(self.options.overcut) + "mm") * scaleXY # mm to dots - self.toolOffset = self.unitToUserUnit(str(self.options.toolOffset) + "mm") * scaleXY # mm to dots + self.offsetX = effect.unittouu(str(self.options.offsetX) + "mm") * self.scaleX # mm to dots (plotter coordinate system) + self.offsetY = effect.unittouu(str(self.options.offsetY) + "mm") * self.scaleY # mm to dots + self.overcut = effect.unittouu(str(self.options.overcut) + "mm") * scaleXY # mm to dots + self.toolOffset = effect.unittouu(str(self.options.toolOffset) + "mm") * scaleXY # mm to dots self.flat = self.options.flat / (1016 / ((self.options.resolutionX + self.options.resolutionY) / 2)) # scale flatness to resolution self.toolOffsetFlat = self.flat / self.toolOffset * 4.5 # scale flatness to offset self.mirrorX = 1.0 @@ -95,23 +86,25 @@ class hpglEncoder: if self.options.mirrorY: self.mirrorY = 1.0 if self.options.debug: - self.debugValues = [0, 0, 0, 0, 0, 0, 0, 0] - self.debugValues[0] = self.docWidth - self.debugValues[1] = self.docHeight + self.debugValues = {} + self.debugValues['docWidth'] = self.docWidth + self.debugValues['docHeight'] = self.docHeight # process viewBox attribute to correct page scaling self.viewBoxTransformX = 1 self.viewBoxTransformY = 1 + if self.options.debug: + self.debugValues['viewBoxWidth'] = "-" + self.debugValues['viewBoxHeight'] = "-" viewBox = self.doc.get('viewBox') if viewBox: - viewBox = string.split(viewBox, ' ') - if viewBox[2] and viewBox[3]: - viewBox[0] = viewBox[2] - viewBox[1] = viewBox[3] + viewBox2 = string.split(viewBox, ',') + if len(viewBox2) < 4: + viewBox2 = string.split(viewBox, ' ') if self.options.debug: - self.debugValues[2] = self.unitToUserUnit(viewBox[0]) - self.debugValues[3] = self.unitToUserUnit(viewBox[1]) - self.viewBoxTransformX = self.docWidth / self.unitToUserUnit(viewBox[0]) - self.viewBoxTransformY = self.docHeight / self.unitToUserUnit(viewBox[1]) + self.debugValues['viewBoxWidth'] = viewBox2[2] + self.debugValues['viewBoxHeight'] = viewBox2[3] + self.viewBoxTransformX = self.docWidth / effect.unittouu(effect.addDocumentUnit(viewBox2[2])) + self.viewBoxTransformY = self.docHeight / effect.unittouu(effect.addDocumentUnit(viewBox2[3])) def getHpgl(self): # dryRun to find edges @@ -124,10 +117,10 @@ class hpglEncoder: # live run self.dryRun = False if self.options.debug: - self.debugValues[4] = self.sizeX - self.divergenceX - self.debugValues[5] = self.sizeY - self.divergenceY - self.debugValues[6] = self.unitToUserUnit(str(self.debugValues[4] / self.scaleX)) - self.debugValues[7] = self.unitToUserUnit(str(self.debugValues[5] / self.scaleY)) + self.debugValues['drawingWidth'] = self.sizeX - self.divergenceX + self.debugValues['drawingHeight'] = self.sizeY - self.divergenceY + self.debugValues['drawingWidthUU'] = self.debugValues['drawingWidth'] / self.scaleX + self.debugValues['drawingHeightUU'] = self.debugValues['drawingHeight'] / self.scaleY # move drawing according to various modifiers if self.options.autoAlign: if self.options.center: @@ -161,20 +154,30 @@ class hpglEncoder: self.offsetX += self.toolOffset self.offsetY += self.toolOffset # initialize transformation matrix and cache - groupmat = [[self.mirrorX * self.scaleX * self.viewBoxTransformX, 0.0, - self.divergenceX + self.offsetX], - [0.0, self.mirrorY * self.scaleY * self.viewBoxTransformY, - self.divergenceY + self.offsetY]] + groupmat = [[self.mirrorX * self.scaleX * self.viewBoxTransformX, 0.0, -self.divergenceX + self.offsetX], + [0.0, self.mirrorY * self.scaleY * self.viewBoxTransformY, -self.divergenceY + self.offsetY]] groupmat = simpletransform.composeTransform(groupmat, simpletransform.parseTransform('rotate(' + self.options.orientation + ')')) self.vData = [['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0]] - # store first hpgl commands + # store initial hpgl commands self.hpgl = 'IN;SP%d' % self.options.pen if self.options.force > 0: self.hpgl += ';FS%d' % self.options.force if self.options.speed > 0: self.hpgl += ';VS%d' % self.options.speed - # add precut + # add move to zero point and precut + self.processOffset('PU', 0, 0) if self.options.useToolOffset and self.options.precut: - self.processOffset('PU', 0, 0) - self.processOffset('PD', 0, self.toolOffset * 8) + if self.options.center: + # TODO: get this FU to work or remove precut functionality + ''' + newDoc = inkex.etree.parse(StringIO('<svg xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" width="10" height="' + str(10 * 3.5433070866) + '"></svg>')) + newLayer = inkex.etree.SubElement(newDoc.getroot(), 'g', {inkex.addNS('groupmode', 'inkscape'): 'layer', inkex.addNS('label', 'inkscape'): 'null'}) + newPath = inkex.etree.SubElement(newLayer, 'path', {'d': 'M ' + str(oldDivergenceX) + ',' + str(oldDivergenceY) + ' L ' + str(oldDivergenceX) + ',' + str(oldDivergenceY + (self.options.toolOffset * 8 * 3.5433070866)), 'style': 'stroke:#000000; stroke-width:0.4; fill:none;'}) + self.processPath(newPath, groupmat) + ''' + pass + else: + self.processOffset('PD', 0, self.toolOffset * 8) # start conversion self.processGroups(self.doc, groupmat) # shift an empty node in in order to process last node in cache @@ -186,20 +189,8 @@ class hpglEncoder: else: return self.hpgl, "" - def unitToUserUnit(self, string, isPixels=False): - '''Returns userunits given a string representation of units in another system''' - matches = re.match('^(.*?)(in|pt|px|mm|cm|km|pc|yd|ft|m)?$', string.strip()) - value = float(matches.group(1)) - unit = matches.group(2) - if unit is None: - if isPixels: - unit = "px" - else: - unit = self.documentUnit - return value * self.__USER_UNIT_CONVERSION[unit] / self.__USER_UNIT_CONVERSION[self.documentUnit] - def processGroups(self, doc, groupmat): - # flatten groups to avoid recursion + # flatten layers and groups to avoid recursion paths = [] for node in doc: if (node.tag == inkex.addNS('g', 'svg') and self.isGroupVisible(node)) or node.tag == inkex.addNS('path', 'svg'): @@ -291,12 +282,6 @@ class hpglEncoder: y = y2 + (y2 - y1) / self.getLength(x1, y1, x2, y2, False) * offset return [x, y] - def getAlpha(self, x1, y1, x2, y2, x3, y3): - # get alpha of point 2 - temp1 = (x1 - x2) ** 2 + (y1 - y2) ** 2 + (x3 - x2) ** 2 + (y3 - y2) ** 2 - (x1 - x3) ** 2 - (y1 - y3) ** 2 - temp2 = 2 * math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) * math.sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2) - return math.acos(max(min(temp1 / temp2, 1.0), -1.0)) - def processOffset(self, cmd, posX, posY): # calculate offset correction (or dont) if not self.options.useToolOffset or self.dryRun: diff --git a/share/extensions/ink2canvas.py b/share/extensions/ink2canvas.py index 51b75d846..d1e11a7c2 100755 --- a/share/extensions/ink2canvas.py +++ b/share/extensions/ink2canvas.py @@ -80,7 +80,7 @@ class Ink2Canvas(inkex.Effect): svg_root = self.document.getroot() width = self.unittouu(svg_root.get("width")) height = self.unittouu(svg_root.get("height")) - self.canvas = Canvas(width, height) + self.canvas = Canvas(self, width, height) self.walk_tree(svg_root) diff --git a/share/extensions/ink2canvas/canvas.py b/share/extensions/ink2canvas/canvas.py index 80ec4fd43..1f574a63e 100644 --- a/share/extensions/ink2canvas/canvas.py +++ b/share/extensions/ink2canvas/canvas.py @@ -23,11 +23,12 @@ import simplestyle class Canvas: """Canvas API helper class""" - def __init__(self, width, height, context = "ctx"): + def __init__(self, parent, width, height, context = "ctx"): self.obj = context self.code = [] #stores the code self.style = {} self.styleCache = {} #stores the previous style applied + self.parent = parent self.width = width self.height = height @@ -117,7 +118,7 @@ class Canvas: self.write("ctx.strokeStyle = %s;" % self.getColor(value, alpha)) def setStrokeWidth(self, value): - self.write("ctx.lineWidth = %f;" % inkex.unittouu(value)) + self.write("ctx.lineWidth = %f;" % self.parent.unittouu(value)) def setStrokeLinecap(self, value): self.write("ctx.lineCap = '%s';" % value) diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index 1203a4606..d71b7d7e7 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -311,5 +311,12 @@ class Effect: def uutounit(self, val, unit): return val / (self.__uuconv[unit] / self.__uuconv[self.getDocumentUnit()]) + def addDocumentUnit(self, value): + ''' Add document unit when no unit is specified in the string ''' + try: + float(value) + return value + self.getDocumentUnit() + except ValueError: + return value # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/interp.py b/share/extensions/interp.py index c69dd4a73..459190c0e 100755 --- a/share/extensions/interp.py +++ b/share/extensions/interp.py @@ -60,10 +60,6 @@ def tweenstylefloat(property, start, end, time): sp = float(start[property]) ep = float(end[property]) return str(sp + (time * (ep - sp))) -def tweenstyleunit(property, start, end, time): - sp = self.unittouu(start[property]) - ep = self.unittouu(end[property]) - return str(sp + (time * (ep - sp))) def tweenstylecolor(property, start, end, time): sr,sg,sb = parsecolor(start[property]) er,eg,eb = parsecolor(end[property]) @@ -107,6 +103,12 @@ class Interp(inkex.Effect): action="store", type="inkbool", dest="style", default=True, help="try interpolation of some style properties") + + def tweenstyleunit(self, property, start, end, time): # moved here so we can call 'unittouu' + sp = self.unittouu(start[property]) + ep = self.unittouu(end[property]) + return str(sp + (time * (ep - sp))) + def effect(self): exponent = self.options.exponent if exponent>= 0: @@ -137,6 +139,8 @@ class Interp(inkex.Effect): sst = copy.deepcopy(styles[self.options.ids[i-1]]) est = copy.deepcopy(styles[self.options.ids[i]]) basestyle = copy.deepcopy(sst) + if basestyle.has_key('stroke-width'): + basestyle['stroke-width'] = self.tweenstyleunit('stroke-width',sst,est,0) #prepare for experimental style tweening if self.options.style: @@ -303,7 +307,7 @@ class Interp(inkex.Effect): basestyle['opacity'] = tweenstylefloat('opacity',sst,est,time) if dostroke: basestyle['stroke-opacity'] = tweenstylefloat('stroke-opacity',sst,est,time) - basestyle['stroke-width'] = tweenstyleunit('stroke-width',sst,est,time) + basestyle['stroke-width'] = self.tweenstyleunit('stroke-width',sst,est,time) basestyle['stroke'] = tweenstylecolor('stroke',sst,est,time) if dofill: basestyle['fill-opacity'] = tweenstylefloat('fill-opacity',sst,est,time) diff --git a/share/extensions/measure.py b/share/extensions/measure.py index 68cce0334..ca471816f 100755 --- a/share/extensions/measure.py +++ b/share/extensions/measure.py @@ -121,7 +121,7 @@ class Length(inkex.Effect): self.OptionParser.add_option("-s", "--scale", action="store", type="float", dest="scale", default=1, - help="The distance above the curve") + help="Scale Factor (Drawing:Real Length)") self.OptionParser.add_option("-r", "--orient", action="store", type="inkbool", dest="orient", default=True, @@ -138,6 +138,7 @@ class Length(inkex.Effect): def effect(self): # get number of digits prec = int(self.options.precision) + self.options.offset *= self.unittouu('1px') factor = 1.0 doc = self.document.getroot() if doc.get('viewBox'): @@ -154,7 +155,7 @@ 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) - factor = factor/self.unittouu('1'+self.options.unit) + factor *= self.unittouu('1px')/self.unittouu('1'+self.options.unit) if self.options.type == "length": slengths, stotal = csplength(p) else: diff --git a/share/extensions/perspective.py b/share/extensions/perspective.py index 8a0ffeb0b..044257ae8 100755 --- a/share/extensions/perspective.py +++ b/share/extensions/perspective.py @@ -54,6 +54,7 @@ class Project(inkex.Effect): exit() #obj is selected second + scale = self.unittouu('1px') # convert to document units obj = self.selected[self.options.ids[0]] envelope = self.selected[self.options.ids[1]] if obj.get(inkex.addNS('type','sodipodi')): @@ -80,11 +81,11 @@ class Project(inkex.Effect): if bsubprocess: p = Popen('inkscape --query-%s --query-id=%s "%s"' % (query,id,file), shell=True, stdout=PIPE, stderr=PIPE) rc = p.wait() - q[query] = float(p.stdout.read()) + q[query] = scale*float(p.stdout.read()) err = p.stderr.read() else: f,err = os.popen3('inkscape --query-%s --query-id=%s "%s"' % (query,id,file))[1:] - q[query] = float(f.read()) + q[query] = scale*float(f.read()) f.close() err.close() sp = array([[q['x'], q['y']+q['height']],[q['x'], q['y']],[q['x']+q['width'], q['y']],[q['x']+q['width'], q['y']+q['height']]], dtype=float64) diff --git a/share/extensions/plotter.inx b/share/extensions/plotter.inx index e30d61418..c8f009140 100644 --- a/share/extensions/plotter.inx +++ b/share/extensions/plotter.inx @@ -80,7 +80,7 @@ <effect needs-live-preview="false"> <object-type>path</object-type> <effects-menu> - <submenu _name="Plotter"/> + <submenu _name="Export"/> </effects-menu> </effect> <script> diff --git a/share/extensions/plotter.py b/share/extensions/plotter.py index 84027b132..67d40a92a 100644 --- a/share/extensions/plotter.py +++ b/share/extensions/plotter.py @@ -191,20 +191,20 @@ class MyEffect(inkex.Effect): fileName = self.document.getroot().xpath('//@sodipodi:docname', namespaces=inkex.NSS) if fileName: inkex.errormsg(' Filename: ' + fileName[0]) - inkex.errormsg(' Document unit: ' + debugObject.documentUnit) - inkex.errormsg(' Width: ' + str(debugObject.debugValues[0]) + ' ' + debugObject.documentUnit) - inkex.errormsg(' Height: ' + str(debugObject.debugValues[1]) + ' ' + debugObject.documentUnit) - if debugObject.debugValues[2] == 0: + inkex.errormsg(' Document unit: ' + self.getDocumentUnit()) + inkex.errormsg(' Width: ' + str(debugObject.debugValues['docWidth']) + ' ' + self.getDocumentUnit()) + inkex.errormsg(' Height: ' + str(debugObject.debugValues['docHeight']) + ' ' + self.getDocumentUnit()) + if debugObject.debugValues['viewBoxWidth'] == "-": inkex.errormsg(' Viewbox Width: -') inkex.errormsg(' Viewbox Height: -') else: - inkex.errormsg(' Viewbox Width: ' + str(debugObject.debugValues[2]) + ' ' + debugObject.documentUnit) - inkex.errormsg(' Viewbox Height: ' + str(debugObject.debugValues[3]) + ' ' + debugObject.documentUnit) + inkex.errormsg(' Viewbox Width: ' + str(self.unittouu(self.addDocumentUnit(debugObject.debugValues['viewBoxWidth']))) + ' ' + self.getDocumentUnit()) + inkex.errormsg(' Viewbox Height: ' + str(self.unittouu(self.addDocumentUnit(debugObject.debugValues['viewBoxHeight']))) + ' ' + self.getDocumentUnit()) inkex.errormsg("\n" + self.options.commandLanguage + " properties:\n") - inkex.errormsg(' Drawing width: ' + str(debugObject.debugValues[6]) + ' ' + debugObject.documentUnit) - inkex.errormsg(' Drawing height: ' + str(debugObject.debugValues[7]) + ' ' + debugObject.documentUnit) - inkex.errormsg(' Drawing width: ' + str(debugObject.debugValues[4]) + ' plotter steps') - inkex.errormsg(' Drawing height: ' + str(debugObject.debugValues[5]) + ' plotter steps') + inkex.errormsg(' Drawing width: ' + str(self.unittouu(self.addDocumentUnit(str(debugObject.debugValues['drawingWidthUU'])))) + ' ' + self.getDocumentUnit()) + inkex.errormsg(' Drawing height: ' + str(self.unittouu(self.addDocumentUnit(str(debugObject.debugValues['drawingHeightUU'])))) + ' ' + self.getDocumentUnit()) + inkex.errormsg(' Drawing width: ' + str(debugObject.debugValues['drawingWidth']) + ' plotter steps') + inkex.errormsg(' Drawing height: ' + str(debugObject.debugValues['drawingHeight']) + ' plotter steps') inkex.errormsg(' Offset X: ' + str(debugObject.offsetX) + ' plotter steps') inkex.errormsg(' Offset Y: ' + str(debugObject.offsetX) + ' plotter steps') inkex.errormsg(' Overcut: ' + str(debugObject.overcut) + ' plotter steps') diff --git a/share/extensions/printing_marks.py b/share/extensions/printing_marks.py index 5c6ac3a61..0306048d6 100755 --- a/share/extensions/printing_marks.py +++ b/share/extensions/printing_marks.py @@ -191,20 +191,21 @@ class Printing_Marks (inkex.Effect): i += 0.1 def get_selection_area(self): + scale = self.unittouu('1px') # convert to document units sel_area = {} min_x, min_y, max_x, max_y = False, False, False, False for id in self.options.ids: sel_area[id] = {} for att in [ "x", "y", "width", "height" ]: args = [ "inkscape", "-I", id, "--query-"+att, self.svg_file ] - sel_area[id][att] = \ - Popen(args, stdout=PIPE, stderr=PIPE).communicate()[0] - current_min_x = float( sel_area[id]["x"] ) - current_min_y = float( sel_area[id]["y"] ) - current_max_x = float( sel_area[id]["x"] ) + \ - float( sel_area[id]["width"] ) - current_max_y = float( sel_area[id]["y"] ) + \ - float( sel_area[id]["height"] ) + sel_area[id][att] = scale* \ + float(Popen(args, stdout=PIPE, stderr=PIPE).communicate()[0]) + current_min_x = sel_area[id]["x"] + current_min_y = sel_area[id]["y"] + current_max_x = sel_area[id]["x"] + \ + sel_area[id]["width"] + current_max_y = sel_area[id]["y"] + \ + sel_area[id]["height"] if not min_x: min_x = current_min_x if not min_y: min_y = current_min_y if not max_x: max_x = current_max_x diff --git a/share/extensions/render_gears.py b/share/extensions/render_gears.py index d5c8131a8..5fdb0d4f6 100644 --- a/share/extensions/render_gears.py +++ b/share/extensions/render_gears.py @@ -35,9 +35,9 @@ def point_on_circle(radius, angle): def points_to_svgd(p): f = p[0] p = p[1:] - svgd = 'M%.3f,%.3f' % f + svgd = 'M%.5f,%.5f' % f for x in p: - svgd += 'L%.3f,%.3f' % x + svgd += ' L%.5f,%.5f' % x svgd += 'z' return svgd diff --git a/share/extensions/summersnight.py b/share/extensions/summersnight.py index aea5cea55..67413a05c 100755 --- a/share/extensions/summersnight.py +++ b/share/extensions/summersnight.py @@ -45,6 +45,7 @@ class Project(inkex.Effect): exit() #obj is selected second + scale = self.unittouu('1px') # convert to document units obj = self.selected[self.options.ids[0]] trafo = self.selected[self.options.ids[1]] if obj.get(inkex.addNS('type','sodipodi')): @@ -75,11 +76,11 @@ class Project(inkex.Effect): if bsubprocess: p = Popen('inkscape --query-%s --query-id=%s "%s"' % (query,id,file), shell=True, stdout=PIPE, stderr=PIPE) rc = p.wait() - self.q[query] = float(p.stdout.read()) + self.q[query] = scale*float(p.stdout.read()) err = p.stderr.read() else: f,err = os.popen3('inkscape --query-%s --query-id=%s "%s"' % (query,id,file))[1:] - self.q[query] = float(f.read()) + self.q[query] = scale*float(f.read()) f.close() err.close() diff --git a/share/extensions/voronoi2svg.py b/share/extensions/voronoi2svg.py index c5b8a511f..289c352e3 100755 --- a/share/extensions/voronoi2svg.py +++ b/share/extensions/voronoi2svg.py @@ -220,15 +220,15 @@ class Voronoi2svg(inkex.Effect): #{{{ Drawing styles linestyle = { - 'stroke' : '#000000', - 'linewidth' : '1', - 'fill' : 'none' + 'stroke' : '#000000', + 'stroke-width' : str(self.unittouu('1px')), + 'fill' : 'none' } facestyle = { - 'stroke' : '#ff0000', - 'linewidth' : '1', - 'fill' : 'none' + 'stroke' : '#ff0000', + 'stroke-width' : str(self.unittouu('1px')), + 'fill' : 'none' } #}}} diff --git a/share/extensions/webslicer_create_rect.py b/share/extensions/webslicer_create_rect.py index 7c04e8706..b4e6858af 100755 --- a/share/extensions/webslicer_create_rect.py +++ b/share/extensions/webslicer_create_rect.py @@ -100,6 +100,7 @@ class WebSlicer_CreateRect(WebSlicer_Effect): self.options.dimension def effect(self): + scale = self.unittouu('1px') # convert to document units self.validate_options() layer = self.get_slicer_layer(True) #TODO: get selected elements to define location and size @@ -110,10 +111,10 @@ class WebSlicer_CreateRect(WebSlicer_Effect): rect.set('id', self.options.name) rect.set('fill', 'red') rect.set('opacity', '0.5') - rect.set('x', '-100') - rect.set('y', '-100') - rect.set('width', '200') - rect.set('height', '200') + rect.set('x', str(-scale*100)) + rect.set('y', str(-scale*100)) + rect.set('width', str(scale*200)) + rect.set('height', str(scale*200)) desc = inkex.etree.SubElement(rect, 'desc') conf_txt = "format:"+ self.options.format +"\n" if not is_empty(self.options.dpi): diff --git a/share/filters/filters.svg b/share/filters/filters.svg index e617d3241..6a5a8afea 100644 --- a/share/filters/filters.svg +++ b/share/filters/filters.svg @@ -419,7 +419,7 @@ sodipodi:docname="filters.svg"> </feSpecularLighting> <feComposite in2="fbSourceGraphic" in="result1" result="result2" operator="in" /> <feComposite in="fbSourceGraphic" result="result4" operator="arithmetic" k2="2" k3="1" in2="result2" /> -<feComposite in2="result4" in="result9" operator="in" result="result91" /> +<feComposite in2="result4" in="result4" operator="in" result="result91" /> <feBlend mode="darken" in2="result91" /> </filter> <filter id="f041" inkscape:label="Matte Bevel" inkscape:menu="Bevels" inkscape:menu-tooltip="Soft, pastel-colored, blurry bevel" x="-0.25" y="-0.25" width="1.5" height="1.5" style="color-interpolation-filters:sRGB;"> @@ -450,7 +450,7 @@ sodipodi:docname="filters.svg"> </feSpecularLighting> <feComposite operator="in" result="result2" in="result1" in2="fbSourceGraphicAlpha" /> <feComposite k3="2" k2="1" operator="arithmetic" result="result4" in="fbSourceGraphic" in2="result2" /> -<feComposite operator="in" in="result9" result="result9" in2="result4" /> +<feComposite operator="in" in="result4" result="result9" in2="result4" /> <feBlend mode="multiply" in="result9" in2="result4" /> </filter> <filter id="f043" inkscape:label="Matte Ridge" inkscape:menu="Ridges" inkscape:menu-tooltip="Soft pastel ridge" style="color-interpolation-filters:sRGB;"> @@ -756,14 +756,12 @@ sodipodi:docname="filters.svg"> <filter id="f067" inkscape:label="Gold Splatter" x="-0.25" y="-0.25" height="1.5" width="1.5" inkscape:menu="Materials" inkscape:menu-tooltip="Splattered cast metal, with golden highlights" style="color-interpolation-filters:sRGB;"> <feGaussianBlur in="SourceAlpha" stdDeviation="1" result="result91" /> <feComposite result="fbSourceGraphic" operator="in" in="SourceGraphic" in2="result91" /> -<feColorMatrix values="0" in="fbSourceGraphic" result="fbSourceGraphicAlpha" type="saturate" /> <feGaussianBlur result="result1" in="fbSourceGraphic" stdDeviation="1" /> <feTurbulence result="result0" numOctaves="7" baseFrequency="0.074 0.084" type="fractalNoise" /> <feDisplacementMap result="result2" scale="80" yChannelSelector="G" xChannelSelector="A" in="result1" in2="result0" /> <feColorMatrix type="saturate" values="1" result="result3" /> <feGaussianBlur result="result4" in="fbSourceGraphic" stdDeviation="1" /> <feComposite operator="atop" result="fbSourceGraphic" in="result4" in2="result3" /> -<feColorMatrix values="0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0" in="fbSourceGraphic" result="fbSourceGraphicAlpha" /> <feGaussianBlur result="result0" in="fbSourceGraphic" stdDeviation="1" /> <feTurbulence baseFrequency="0.062" seed="488" numOctaves="8" result="result1" type="fractalNoise" /> <feComposite result="result2" operator="out" in2="result1" in="result0" /> @@ -776,14 +774,12 @@ sodipodi:docname="filters.svg"> <filter id="f068" inkscape:label="Gold Paste" x="-0.25" y="-0.25" height="1.5" width="1.5" inkscape:menu="Materials" inkscape:menu-tooltip="Fat pasted cast metal, with golden highlights" style="color-interpolation-filters:sRGB;"> <feGaussianBlur in="SourceAlpha" stdDeviation="0.01" result="result91" /> <feComposite result="fbSourceGraphic" operator="in" in="SourceGraphic" in2="result91" /> -<feColorMatrix values="1" in="fbSourceGraphic" result="fbSourceGraphicAlpha" type="saturate" /> <feGaussianBlur result="result1" in="fbSourceGraphic" stdDeviation="0.01" /> <feTurbulence result="result0" numOctaves="4" baseFrequency="0.04" type="fractalNoise" seed="20" /> <feDisplacementMap result="result2" scale="30" yChannelSelector="G" xChannelSelector="R" in="result1" in2="result0" /> <feColorMatrix type="saturate" values="1" result="result3" /> <feGaussianBlur result="result4" in="fbSourceGraphic" stdDeviation="0.01" /> <feComposite operator="atop" result="fbSourceGraphic" in="result4" in2="result3" /> -<feColorMatrix values="0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0" in="fbSourceGraphic" result="fbSourceGraphicAlpha" /> <feGaussianBlur result="result0" in="fbSourceGraphic" stdDeviation="1.5" /> <feTurbulence baseFrequency="0.02" seed="20" numOctaves="8" result="result1" type="fractalNoise" /> <feComposite result="result2" operator="out" in2="result1" in="result0" /> @@ -999,7 +995,6 @@ sodipodi:docname="filters.svg"> </filter> <filter id="f094" inkscape:label="Chalk and Sponge" inkscape:menu="Distort" inkscape:menu-tooltip="Low turbulence gives sponge look and high turbulence chalk" width="1.6" height="2" y="-0.5" x="-0.3" style="color-interpolation-filters:sRGB;"> <feTurbulence baseFrequency="0.4" type="fractalNoise" seed="0" numOctaves="5" result="result1" /> -<feOffset dx="-5" dy="-5" result="result2" /> <feDisplacementMap xChannelSelector="R" yChannelSelector="G" scale="30" in="SourceGraphic" in2="result1" /> </filter> <filter id="f095" inkscape:label="People" inkscape:menu="Overlays" inkscape:menu-tooltip="Colorized blotches, like a crowd of people" style="color-interpolation-filters:sRGB;"> @@ -1701,7 +1696,6 @@ sodipodi:docname="filters.svg"> </filter> <filter id="f166" inkscape:label="Tinfoil" inkscape:menu-tooltip="Metallic foil effect combining two lighting types and variable crumple" inkscape:menu="Bumps" height="1.4" width="1.4" x="-0.2" y="-0.2" style="color-interpolation-filters:sRGB;"> <feGaussianBlur in="SourceGraphic" result="result14" stdDeviation="0.5" /> -<feFlood flood-color="rgb(127,126,123)" result="result15" flood-opacity="1" /> <feTurbulence type="fractalNoise" seed="25" baseFrequency="0.004 0.008" numOctaves="1" result="result5" /> <feDisplacementMap scale="100" xChannelSelector="R" in="result5" result="result8" yChannelSelector="B" in2="result14" /> <feGaussianBlur stdDeviation="0.5" result="result17" /> @@ -1769,7 +1763,9 @@ sodipodi:docname="filters.svg"> <filter id="f171" inkscape:label="Pixellize" inkscape:menu="Pixel tools" inkscape:menu-tooltip="Reduce or remove antialiasing around shapes" style="color-interpolation-filters:sRGB;"> <feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1000 -500 " /> </filter> +<!-- empty filter <filter id="f172" inkscape:label="Set Resolution" inkscape:menu="Pixel tools" inkscape:menu-tooltip="Set filter resolution" filterRes="1000 1000" style="color-interpolation-filters:sRGB;" /> +--> <filter id="f173" inkscape:label="Basic Diffuse Bump" inkscape:menu="Bumps" inkscape:menu-tooltip="Matte emboss effect" style="color-interpolation-filters:sRGB;"> <feColorMatrix result="result2" type="luminanceToAlpha" in="SourceGraphic" /> <feDiffuseLighting lighting-color="#ffffff" in="result2" diffuseConstant="0.5" result="result1" surfaceScale="15"> @@ -1952,11 +1948,6 @@ sodipodi:docname="filters.svg"> <feMergeNode in="SourceGraphic" /> </feMerge> </filter> -<filter id="f192" inkscape:label="Fill Area" inkscape:menu="Fill and Transparency" inkscape:menu-tooltip="Fills object bounding box with color" style="color-interpolation-filters:sRGB;"> -<feImage xlink:href="" result="result2" /> -<feFlood flood-color="rgb(76,141,122)" flood-opacity="1" result="result1" /> -<feBlend in2="result2" mode="normal" /> -</filter> <filter id="f193" inkscape:label="Blur Double" inkscape:menu="Blurs" inkscape:menu-tooltip="Overlays two copies with different blur amounts and modifiable blend and composite" style="color-interpolation-filters:sRGB;"> <feGaussianBlur stdDeviation="5" result="fbSourceGraphic" /> <feGaussianBlur stdDeviation="0.01" in="SourceGraphic" result="result1" /> @@ -2103,7 +2094,7 @@ sodipodi:docname="filters.svg"> <feColorMatrix in="result5" type="saturate" values="0" result="result4" /> <feComposite in2="result6" result="result2" k3="0.5" k2="0.5" k1="1.5" operator="arithmetic" in="result4" /> <feBlend result="result7" mode="normal" in2="result4" /> -<feComposite in2="SourceGraphic" result="result3" operator="in" in="result8" /> +<feComposite in2="SourceGraphic" result="result3" operator="in" in="result7" /> </filter> <filter id="f205" inkscape:label="Cross Noise" inkscape:menu="Overlays" inkscape:menu-tooltip="Adds a small scale screen like graininess" style="color-interpolation-filters:sRGB;"> <feTurbulence type="fractalNoise" numOctaves="5" baseFrequency="1" seed="0" result="result0" /> @@ -2129,7 +2120,6 @@ sodipodi:docname="filters.svg"> <feComposite in2="SourceGraphic" operator="in" /> </filter> <filter id="f207" inkscape:label="Light Eraser Cracked" style="color-interpolation-filters:sRGB;" inkscape:menu-tooltip="Basic noise fill texture; adjust color in Flood" inkscape:menu="Overlays"> -<feBlend in2="SourceGraphic" mode="normal" /> <feColorMatrix result="fbSourceGraphic" type="luminanceToAlpha" in="SourceGraphic" /> <feColorMatrix result="result6" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 " /> <feComposite in2="result6" result="result2" operator="out" in="SourceGraphic" k2="0" k1="1" k3="0" /> @@ -2225,7 +2215,6 @@ sodipodi:docname="filters.svg"> <feGaussianBlur in="SourceGraphic" stdDeviation="5" result="result8" /> <feComposite in2="result8" operator="xor" result="result19" /> <feComposite k2="1" operator="arithmetic" result="result17" in2="result8" /> -<feComposite in2="result17" result="result6" operator="xor" in="result17" /> <feOffset result="result18" in="SourceGraphic" /> <feDisplacementMap in2="result17" in="result18" xChannelSelector="A" yChannelSelector="A" scale="100" result="result4" /> <feComposite in2="result4" result="result2" operator="arithmetic" in="SourceGraphic" k3="1" /> @@ -2249,7 +2238,6 @@ sodipodi:docname="filters.svg"> <feGaussianBlur stdDeviation="5" result="result8" in="SourceGraphic" /> <feComposite operator="xor" result="result18" in2="result8" /> <feComposite k2="1" operator="arithmetic" result="result16" in2="result18" in="result8" /> -<feComposite in2="result16" result="result6" operator="xor" in="result16" /> <feOffset result="result17" in="SourceGraphic" /> <feDisplacementMap in2="result18" in="result17" xChannelSelector="A" yChannelSelector="A" scale="100" result="result4" /> <feComposite in2="result4" result="result2" operator="arithmetic" in="SourceGraphic" k1="0" k3="1" /> @@ -2261,7 +2249,6 @@ sodipodi:docname="filters.svg"> <feGaussianBlur in="SourceGraphic" stdDeviation="5" result="result8" /> <feComposite in2="result8" operator="xor" result="result19" /> <feComposite k2="1" operator="arithmetic" result="result17" in2="result8" /> -<feComposite in2="result17" result="result6" operator="xor" in="result17" /> <feOffset result="result18" in="result8" /> <feDisplacementMap in2="result17" in="result18" xChannelSelector="A" yChannelSelector="A" scale="100" result="result4" /> <feComposite in2="result4" result="result2" operator="arithmetic" in="SourceGraphic" k1="0" k3="1" /> @@ -2285,7 +2272,6 @@ sodipodi:docname="filters.svg"> <feGaussianBlur stdDeviation="5" result="result8" in="SourceGraphic" /> <feComposite in2="result8" operator="xor" /> <feComposite k2="1" operator="arithmetic" result="result17" in2="result8" /> -<feComposite in2="result17" result="result6" operator="xor" in="result17" /> <feOffset result="result18" in="result17" /> <feDisplacementMap in2="result17" in="result18" xChannelSelector="A" yChannelSelector="A" scale="100" result="result4" /> <feComposite in2="result4" result="fbSourceGraphic" operator="arithmetic" in="result4" k1="1" k3="1" /> @@ -2297,7 +2283,6 @@ sodipodi:docname="filters.svg"> <feGaussianBlur result="result8" stdDeviation="5" in="SourceGraphic" /> <feComposite result="result19" operator="xor" in2="result8" /> <feComposite in2="result8" result="result17" operator="arithmetic" k2="1" /> -<feComposite in="result17" operator="xor" result="result6" in2="result17" /> <feOffset in="result8" result="result18" /> <feDisplacementMap result="result4" scale="100" yChannelSelector="A" xChannelSelector="A" in="result18" in2="result17" /> <feComposite k3="1" k1="1" in="SourceGraphic" operator="arithmetic" result="result2" in2="result4" /> @@ -2309,7 +2294,6 @@ sodipodi:docname="filters.svg"> <feGaussianBlur result="result8" stdDeviation="5" in="SourceGraphic" /> <feComposite result="result19" operator="xor" in2="result8" /> <feComposite in2="result8" result="result17" operator="arithmetic" k2="1" /> -<feComposite in="result17" operator="xor" result="result6" in2="result17" /> <feOffset in="result8" result="result18" /> <feDisplacementMap result="result4" scale="100" yChannelSelector="A" xChannelSelector="A" in="result18" in2="result17" /> <feComposite k3="0.5" k1="0.5" in="result4" operator="arithmetic" result="result2" in2="result4" /> @@ -2497,7 +2481,6 @@ sodipodi:docname="filters.svg"> </feComponentTransfer> <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.21 -0.72 -0.07 1 0 " in="fbSourceGraphic" result="result1" /> <feFlood flood-color="rgb(144,7,7)" result="result3" flood-opacity="1" /> -<feComposite in2="result1" operator="in" result="result5" /> <feBlend in2="fbSourceGraphic" mode="screen" in="result3" result="result4" /> <feComposite in2="SourceGraphic" operator="in" in="result4" result="result2" /> </filter> |
