summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9527109)
raw | patch | inline | side by side (parent: 9527109)
author | acspike <acspike@users.sourceforge.net> | |
Fri, 24 Nov 2006 18:53:21 +0000 (18:53 +0000) | ||
committer | acspike <acspike@users.sourceforge.net> | |
Fri, 24 Nov 2006 18:53:21 +0000 (18:53 +0000) |
index 176412ea3e279195606c14fc6fb6c447f22b38b7..e8eff2c01f892b8c5ce19e21b5a536aae0089cbb 100755 (executable)
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, simplepath, cubicsuperpath, re
-\r
-uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'pc':15.0}\r
-def unittouu(string):\r
- unit = re.compile('(%s)$' % '|'.join(uuconv.keys()))\r
- param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)')\r
-\r
- p = param.match(string)\r
- u = unit.search(string) \r
- if p:\r
- retval = float(p.string[p.start():p.end()])\r
- else:\r
- retval = 0.0\r
- if u:\r
- try:\r
- return retval * uuconv[u.string[u.start():u.end()]]\r
- except KeyError:\r
- pass\r
- return retval\r
+import inkex, simplepath, cubicsuperpath
class MyEffect(inkex.Effect):
def __init__(self):
self.dxf_add("999\nDXF created by Inkscape\n0\nSECTION\n2\nENTITIES")\r
\r
scale = 25.4/90.0
- h = unittouu(inkex.xml.xpath.Evaluate('/svg/@height',self.document)[0].value)\r
+ h = inkex.unittouu(inkex.xml.xpath.Evaluate('/svg/@height',self.document)[0].value)\r
path = '//path'
for node in inkex.xml.xpath.Evaluate(path,self.document):\r
index 1ce58d7417fdf58620475abd0d0c61ddaac842cd..4bf977b9b9870674fd0eb224133f379fdcfca4fe 100755 (executable)
u'xlink' :u'http://www.w3.org/1999/xlink'
}
+#a dictionary of unit to user unit conversion factors
+uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'pc':15.0}
+def unittouu(string):
+ '''Returns returns userunits given a string representation of units in another system'''
+ unit = re.compile('(%s)$' % '|'.join(uuconv.keys()))
+ param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)')
+
+ 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 * uuconv[u.string[u.start():u.end()]]
+ except KeyError:
+ pass
+ return retval
+
try:
import xml.dom.ext
import xml.dom.minidom
index ba8d8d7f40f6ec8b2e1494c5f4cc871b2704bc09..f0ba8f26c883f42ed41dfec4b63a1653b3003181 100755 (executable)
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, re, bezmisc
+import inkex, cubicsuperpath, simplestyle, copy, math, bezmisc
-uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'pc':15.0}
def numsegs(csp):
return sum([len(p)-1 for p in csp])
def interpcoord(v1,v2,p):
lengths[-1].append(l)
total += l
return lengths, total
-def styleunittouu(string):
- unit = re.compile('(%s)$' % '|'.join(uuconv.keys()))
- param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)')
-
- 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 * uuconv[u.string[u.start():u.end()]]
- except KeyError:
- pass
- return retval
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 = styleunittouu(start[property])
- ep = styleunittouu(end[property])
+ sp = inkex.unittouu(start[property])
+ ep = inkex.unittouu(end[property])
return str(sp + (time * (ep - sp)))
def tweenstylecolor(property, start, end, time):
sr,sg,sb = parsecolor(start[property])
index b94d2b9b7786b33a0f65cdd6277705a0edced162..2fca74a50ae2cd456a53a5e50070b166530a6728 100755 (executable)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
-import inkex, os, re, simplepath, cubicsuperpath
+import inkex, os, simplepath, cubicsuperpath
from ffgeom import *
-uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'pc':15.0}
-def unittouu(string):
- unit = re.compile('(%s)$' % '|'.join(uuconv.keys()))
- param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)')
-
- 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 * uuconv[u.string[u.start():u.end()]]
- except KeyError:
- pass
- return retval
-
class Project(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.q[query] = float(f.read())
f.close()
#glean document height from the SVG
- docheight = unittouu(inkex.xml.xpath.Evaluate('/svg/@height',self.document)[0].value)
+ docheight = inkex.unittouu(inkex.xml.xpath.Evaluate('/svg/@height',self.document)[0].value)
#Flip inkscapes transposed renderer coords
self.q['y'] = docheight - self.q['y'] - self.q['height']