summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlvin Penner <penner@vaxxine.com>2014-02-16 00:13:08 +0000
committerapenner <penner@vaxxine.com>2014-02-16 00:13:08 +0000
commit7ed3c6cbcc209af64384bea1489398a28381a9ce (patch)
treee8f622ecefcc83af802ca45ffe382caa74770740
parentSymbols: turn off viewBox-related debug messages (from r13002) (diff)
downloadinkscape-7ed3c6cbcc209af64384bea1489398a28381a9ce.tar.gz
inkscape-7ed3c6cbcc209af64384bea1489398a28381a9ce.zip
Extensions. Scaling of stroke and some sizes into document units, Part 5 (Bug 1240455)
(bzr r13030)
-rwxr-xr-xshare/extensions/dots.py2
-rwxr-xr-xshare/extensions/interp.py14
-rwxr-xr-xshare/extensions/voronoi2svg.py12
-rwxr-xr-xshare/extensions/webslicer_create_rect.py9
4 files changed, 21 insertions, 16 deletions
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/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/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):