summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 69f4809)
raw | patch | inline | side by side (parent: 69f4809)
author | acspike <acspike@users.sourceforge.net> | |
Wed, 20 Jun 2007 03:31:47 +0000 (03:31 +0000) | ||
committer | acspike <acspike@users.sourceforge.net> | |
Wed, 20 Jun 2007 03:31:47 +0000 (03:31 +0000) |
index fcb20dde4f8497c11c8977d1189dc7ce59e41047..76887faf0f21ca25525d29abdb1be83d767d43dc 100644 (file)
#inkex.debug("visited: " + str(self.visited))\r
newnode = inkex.etree.fromstring(inkex.etree.tostring(node))\r
newnode.set('id', newid)\r
- node.xpath('..')[0].append(newnode)\r
+ node.getparent().append(newnode)\r
self.changeStyle(newnode)\r
for child in newnode:\r
self.changeStyle(child)\r
index ca235861c8ae6026369037d55bd9a1a15e8fbdc1..7350cae8dacc89b3d5e3a54a65887e0cf424efbe 100755 (executable)
--- a/share/extensions/dots.py
+++ b/share/extensions/dots.py
def effect(self):
for id, node in self.selected.iteritems():
if node.tag == inkex.addNS('path','svg'):
- self.group = inkex.etree.SubElement(node.xpath('..')[0],inkex.addNS('g','svg'))
+ self.group = inkex.etree.SubElement(node.getparent(),inkex.addNS('g','svg'))
new = inkex.etree.SubElement(self.group,inkex.addNS('path','svg'))
try:
index bcb69237a92821519ae42a7d3c9262c27ba4be49..0192da0221116d62c442fae3728fe003f46fca9b 100644 (file)
clip.append(inkex.etree.fromstring(inkex.etree.tostring(node)))
clipId = self.uniqueId('clipPath')
clip.set('id', clipId)
- clipG = inkex.etree.SubElement(node.xpath('..')[0],inkex.addNS('g','svg'))
+ clipG = inkex.etree.SubElement(node.getparent(),inkex.addNS('g','svg'))
g = inkex.etree.SubElement(clipG,inkex.addNS('g','svg'))
clipG.set('clip-path', 'url(#'+clipId+')')
# make a blur filter reference by the style of each path
fe.set('stdDeviation', str(self.options.stddev))
else:
# can't find defs, just group paths
- g = inkex.etree.SubElement(node.xpath('..')[0],inkex.addNS('g','svg'))\r
+ g = inkex.etree.SubElement(node.getparent(),inkex.addNS('g','svg'))\r
g.append(node)
return g
index f0540ac507f8fc1e35758d0872228f91cde85fd9..188cb5d60f73c0555b13d0136390dd7db9b5adfa 100644 (file)
'icon':'.ico',
'gif' :'.gif'
}
- #ctx = inkex.xml.xpath.Context.Context(self.document,processorNss=inkex.NSS)
# exbed the first embedded image
path = self.options.filepath
if (path != ''):
if (self.options.ids):
for id, node in self.selected.iteritems():
- if node.tagName == 'image':
- xlink = node.attributes.getNamedItemNS(inkex.NSS[u'xlink'],'href')
- if (xlink.value[:4]=='data'):
- comma = xlink.value.find(',')
+ if node.tag == inkex.addNS('image','svg'):
+ xlink = node.get(inkex.addNS('href','xlink'))
+ if (xlink[:4]=='data'):
+ comma = xlink.find(',')
if comma>0:
#get extension
fileext=''
- semicolon = xlink.value.find(';')
+ semicolon = xlink.find(';')
if semicolon>0:
for sub in mimesubext.keys():
- if sub in xlink.value[5:semicolon]:
+ if sub in xlink[5:semicolon]:
fileext=mimesubext[sub]
path=path+fileext;
break
#save
- data = base64.decodestring(xlink.value[comma:])
+ data = base64.decodestring(xlink[comma:])
open(path,'wb').write(data)
- xlink.value = os.path.realpath(path) #absolute for making in-mem cycles work
+ node.set(inkex.addNS('href','xlink'),os.path.realpath(path)) #absolute for making in-mem cycles work
else:
inkex.debug('Difficulty finding the image data.')
break
index 8dc4e393b3beb958e6b280e50682d8aead138e03..2e1a491cd3368c87c6c4503a2401d075782cd286 100755 (executable)
help="Minimum flatness of the subdivided curves")
def effect(self):
for id, node in self.selected.iteritems():
- if node.tagName == 'path':
- d = node.attributes.getNamedItem('d')
- p = cubicsuperpath.parsePath(d.value)
+ if node.tag == inkex.addNS('path','svg'):
+ d = node.get('d')
+ p = cubicsuperpath.parsePath(d)
cspsubdiv.cspsubdiv(p, self.options.flat)
np = []
for sp in p:
cmd = 'M'
first = False
np.append([cmd,[csp[1][0],csp[1][1]]])
- d.value = simplepath.formatPath(np)
+ node.set('d',simplepath.formatPath(np))
e = MyEffect()
e.affect()
\ No newline at end of file
index 7b4dc2ea312ca500c56daba49b9e2f6813a9ead3..8ec9f80aed078f14c255d9052165045c126056f8 100755 (executable)
along with this program; if not, write to the Free Software\r
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
'''\r
-import random, math, inkex, simplestyle, simplepath\r
+import random, math, inkex, simplepath\r
\r
def calculateSubdivision(x1,y1,x2,y2,smoothness):\r
- """ Calculate the vector from (x1,y1) to (x2,y2) """\r
- x3 = x2 - x1\r
- y3 = y2 - y1\r
- """ Calculate the point half-way between the two points """\r
- hx = x1 + x3/2\r
- hy = y1 + y3/2\r
- """ Calculate normalized vector perpendicular to the vector (x3,y3) """\r
- length = math.sqrt(x3*x3 + y3*y3)\r
- nx = -y3/length\r
- ny = x3/length\r
- """ Scale perpendicular vector by random factor """\r
- r = random.uniform(-length/(1+smoothness),length/(1+smoothness))\r
- nx = nx * r\r
- ny = ny * r\r
- """ add scaled perpendicular vector to the half-way point to get the final\r
- displaced subdivision point """\r
- x = hx + nx\r
- y = hy + ny\r
- return [x, y]\r
+ """ Calculate the vector from (x1,y1) to (x2,y2) """\r
+ x3 = x2 - x1\r
+ y3 = y2 - y1\r
+ """ Calculate the point half-way between the two points """\r
+ hx = x1 + x3/2\r
+ hy = y1 + y3/2\r
+ """ Calculate normalized vector perpendicular to the vector (x3,y3) """\r
+ length = math.sqrt(x3*x3 + y3*y3)\r
+ nx = -y3/length\r
+ ny = x3/length\r
+ """ Scale perpendicular vector by random factor """\r
+ r = random.uniform(-length/(1+smoothness),length/(1+smoothness))\r
+ nx = nx * r\r
+ ny = ny * r\r
+ """ add scaled perpendicular vector to the half-way point to get the final\r
+ displaced subdivision point """\r
+ x = hx + nx\r
+ y = hy + ny\r
+ return [x, y]\r
\r
class PathFractalize(inkex.Effect):\r
- def __init__(self):\r
- inkex.Effect.__init__(self)\r
- self.OptionParser.add_option("-s", "--subdivs",\r
- action="store", type="int", \r
- dest="subdivs", default="6",\r
- help="Number of subdivisons")\r
- self.OptionParser.add_option("-f", "--smooth",\r
- action="store", type="float", \r
- dest="smooth", default="4.0",\r
- help="Smoothness of the subdivision")\r
- def effect(self):\r
- for id, node in self.selected.iteritems():\r
- if node.tagName == 'path':\r
- d = node.attributes.getNamedItem('d')\r
- p = simplepath.parsePath(d.value)\r
- new = self.document.createElement('svg:path')\r
- try:\r
- t = node.attributes.getNamedItem('transform').value\r
- new.setAttribute('transform', t)\r
- except AttributeError:\r
- pass\r
-\r
- s = simplestyle.parseStyle(node.attributes.getNamedItem('style').value)\r
- new.setAttribute('style', simplestyle.formatStyle(s))\r
- \r
- a = []\r
- p = simplepath.parsePath(node.attributes.getNamedItem('d').value)\r
- first = 1\r
- for cmd,params in p:\r
- if cmd != 'Z':\r
- if first == 1:\r
- x1 = params[-2]\r
- y1 = params[-1]\r
- a.append(['M',params[-2:]])\r
- first = 2\r
- else :\r
- x2 = params[-2]\r
- y2 = params[-1]\r
- self.fractalize(a,x1,y1,x2,y2,self.options.subdivs,self.options.smooth)\r
- x1 = x2\r
- y1 = y2\r
- a.append(['L',params[-2:]])\r
+ def __init__(self):\r
+ inkex.Effect.__init__(self)\r
+ self.OptionParser.add_option("-s", "--subdivs",\r
+ action="store", type="int", \r
+ dest="subdivs", default="6",\r
+ help="Number of subdivisons")\r
+ self.OptionParser.add_option("-f", "--smooth",\r
+ action="store", type="float", \r
+ dest="smooth", default="4.0",\r
+ help="Smoothness of the subdivision")\r
+ def effect(self):\r
+ for id, node in self.selected.iteritems():\r
+ if node.tag == inkex.addNS('path','svg'):\r
+ d = node.get('d')\r
+ p = simplepath.parsePath(d)\r
+ \r
+ a = []\r
+ first = 1\r
+ for cmd,params in p:\r
+ if cmd != 'Z':\r
+ if first == 1:\r
+ x1 = params[-2]\r
+ y1 = params[-1]\r
+ a.append(['M',params[-2:]])\r
+ first = 2\r
+ else :\r
+ x2 = params[-2]\r
+ y2 = params[-1]\r
+ self.fractalize(a,x1,y1,x2,y2,self.options.subdivs,self.options.smooth)\r
+ x1 = x2\r
+ y1 = y2\r
+ a.append(['L',params[-2:]])\r
\r
- new.setAttribute('d', simplepath.formatPath(a))\r
- node.parentNode.appendChild(new)\r
- node.parentNode.removeChild(node)\r
+ node.set('d', simplepath.formatPath(a))\r
\r
- def fractalize(self,a,x1,y1,x2,y2,s,f):\r
- subdivPoint = calculateSubdivision(x1,y1,x2,y2,f)\r
- \r
- if s > 0 :\r
- """ recursively subdivide the segment left of the subdivision point """\r
- self.fractalize(a,x1,y1,subdivPoint[-2],subdivPoint[-1],s-1,f)\r
- a.append(['L',subdivPoint])\r
- """ recursively subdivide the segment right of the subdivision point """\r
- self.fractalize(a,subdivPoint[-2],subdivPoint[-1],x2,y2,s-1,f)\r
+ def fractalize(self,a,x1,y1,x2,y2,s,f):\r
+ subdivPoint = calculateSubdivision(x1,y1,x2,y2,f)\r
+ \r
+ if s > 0 :\r
+ """ recursively subdivide the segment left of the subdivision point """\r
+ self.fractalize(a,x1,y1,subdivPoint[-2],subdivPoint[-1],s-1,f)\r
+ a.append(['L',subdivPoint])\r
+ """ recursively subdivide the segment right of the subdivision point """\r
+ self.fractalize(a,subdivPoint[-2],subdivPoint[-1],x2,y2,s-1,f)\r
\r
e = PathFractalize()\r
e.affect()\r
index fb0a9ecb6e1f7db34b4faa445ef1ccfd01267923..f0e84d6f68f87fe25bd3d34985f50c2ec2e49664 100644 (file)
\r
def effect(self):\r
for id, node in self.selected.iteritems():\r
- if node.tagName == 'rect':\r
+ if node.tag == inkex.addNS('rect','svg'):\r
# create new path with basic dimensions of selected rectangle\r
- newpath = self.document.createElement('svg:path')\r
- x = float(node.attributes.getNamedItem('x').value)\r
- y = float(node.attributes.getNamedItem('y').value)\r
- w = float(node.attributes.getNamedItem('width').value)\r
- h = float(node.attributes.getNamedItem('height').value)\r
+ newpath = inkex.etree.Element(inkex.addNS('path','svg'))\r
+ x = float(node.get('x'))\r
+ y = float(node.get('y'))\r
+ w = float(node.get('width'))\r
+ h = float(node.get('height'))\r
\r
#copy attributes of rect\r
- s = node.attributes.getNamedItem('style').value\r
- newpath.setAttribute('style', s)\r
+ s = node.get('style')\r
+ newpath.set('style', s)\r
try:\r
- t = node.attributes.getNamedItem('transform').value\r
- newpath.setAttribute('transform', t)\r
+ t = node.get('transform')\r
+ newpath.set('transform', t)\r
except AttributeError:\r
pass\r
\r
# top and bottom where exchanhged\r
- newpath.setAttribute('d', simplepath.formatPath(\r
+ newpath.set('d', simplepath.formatPath(\r
drawfunction(self.options.xstart,\r
self.options.xend,\r
self.options.ybottom,\r
self.options.times2pi,\r
self.options.isoscale,\r
self.options.drawaxis)))\r
- newpath.setAttribute('title', self.options.fofx)\r
+ newpath.set('title', self.options.fofx)\r
\r
#newpath.setAttribute('desc', '!func;' + self.options.fofx + ';' \r
# + self.options.fpofx + ';'\r
# + `self.options.samples`)\r
\r
# add path into SVG structure\r
- node.parentNode.appendChild(newpath)\r
+ node.getparent().append(newpath)\r
# option wether to remove the rectangle or not.\r
if self.options.remove:\r
- node.parentNode.removeChild(node)\r
+ node.getparent().remove(node)\r
\r
e = FuncPlot()\r
e.affect()\r
index 5ce41b734a6a82c3e739507e8e9232924c9bfa2c..83d7f196910d649c2b4be95055ffc062406d122f 100755 (executable)
class Handles(inkex.Effect):
def effect(self):
for id, node in self.selected.iteritems():
- if node.tagName == 'path':
- p = simplepath.parsePath(node.attributes.getNamedItem('d').value)
+ if node.tag == inkex.addNS('path','svg'):
+ p = simplepath.parsePath(node.get('d'))
a =[]
pen = None
subPathStart = None
pen = params[-2:]
if len(a) > 0:
- new = self.document.createElement('svg:path')
s = {'stroke-linejoin': 'miter', 'stroke-width': '1.0px',
'stroke-opacity': '1.0', 'fill-opacity': '1.0',
'stroke': '#000000', 'stroke-linecap': 'butt',
'fill': 'none'}
- new.setAttribute('style', simplestyle.formatStyle(s))
- new.setAttribute('d', simplepath.formatPath(a))
- node.parentNode.appendChild(new)
-
+ attribs = {'style':simplestyle.formatStyle(s),'d':simplepath.formatPath(a)}
+ inkex.etree.SubElement(node.getparent(), inkex.addNS('path','svg'), attribs)
+
e = Handles()
e.affect()
index f0ba8f26c883f42ed41dfec4b63a1653b3003181..1b28f1bffd9a97dfa1e02d6f1e1bef3735e7f1c6 100755 (executable)
styles = {}
for id in self.options.ids:
node = self.selected[id]
- if node.tagName =='path':
- paths[id] = cubicsuperpath.parsePath(node.attributes.getNamedItem('d').value)
- styles[id] = simplestyle.parseStyle(node.attributes.getNamedItem('style').value)
+ if node.tag ==inkex.addNS('path','svg'):
+ paths[id] = cubicsuperpath.parsePath(node.get('d'))
+ styles[id] = simplestyle.parseStyle(node.get('style'))
else:
self.options.ids.remove(id)
if self.options.dup:
steps = [0] + steps + [1]
#create an interpolated path for each interval
- group = self.document.createElement('svg:g')
- self.current_layer.appendChild(group)
+ group = inkex.etree.SubElement(self.current_layer,inkex.addNS('g','svg'))
for time in steps:
interp = []
#process subpaths
#remove final subpath if empty.
if not interp[-1]:
del interp[-1]
- new = self.document.createElement('svg:path')
#basic style tweening
if self.options.style:
if dofill:
basestyle['fill-opacity'] = tweenstylefloat('fill-opacity',sst,est,time)
basestyle['fill'] = tweenstylecolor('fill',sst,est,time)
- new.setAttribute('style', simplestyle.formatStyle(basestyle))
- new.setAttribute('d', cubicsuperpath.formatPath(interp))
- group.appendChild(new)
+ attribs = {'style':simplestyle.formatStyle(basestyle),'d':cubicsuperpath.formatPath(interp)}
+ new = inkex.etree.SubElement(group,inkex.addNS('path','svg'), attribs)
e = Interp()
e.affect()