summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 40d7846)
raw | patch | inline | side by side (parent: 40d7846)
| author | acspike <acspike@users.sourceforge.net> | |
| Wed, 10 May 2006 22:00:58 +0000 (22:00 +0000) | ||
| committer | acspike <acspike@users.sourceforge.net> | |
| Wed, 10 May 2006 22:00:58 +0000 (22:00 +0000) |
| share/extensions/bezmisc.py | patch | blob | history | |
| share/extensions/summersnight.py | patch | blob | history |
index e8cc8c2e9a2ed8ed3034bf6995fc980ffa61b137..f52fb672803af7228a7e6a7fd5649d28e988e5c9 100755 (executable)
@@ -69,14 +69,14 @@ def linebezierintersect(((lx1,ly1),(lx2,ly2)),((bx0,by0),(bx1,by1),(bx2,by2),(bx
c=coef1*cy-coef2*cx
d=coef1*(y0-bb)-coef2*(x0-dd)
- roots = rootWrapper(a,b,c,d)
- retval = []
- for i in roots:
- if type(i) is complex and i.imag==0:
- i = i.real
- if type(i) is not complex and 0<=i<=1:
- retval.append(i)
- return retval
+ roots = rootWrapper(a,b,c,d)
+ retval = []
+ for i in roots:
+ if type(i) is complex and i.imag==0:
+ i = i.real
+ if type(i) is not complex and 0<=i<=1:
+ retval.append(i)
+ return retval
def bezierpointatt(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)),t):
ax,ay,bx,by,cx,cy,x0,y0=bezierparameterize(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)))
index 6f39170ebdc617a4b6d46f5c25f1ffdb7b4d015a..b94d2b9b7786b33a0f65cdd6277705a0edced162 100755 (executable)
return retval
class Project(inkex.Effect):
- def __init__(self):
- inkex.Effect.__init__(self)
- def effect(self):
- if len(self.options.ids) < 2:
- inkex.debug("Requires two selected paths. The second must be exctly four nodes long.")
- exit()
+ def __init__(self):
+ inkex.Effect.__init__(self)
+ def effect(self):
+ if len(self.options.ids) < 2:
+ inkex.debug("Requires two selected paths. The second must be exctly four nodes long.")
+ exit()
- #obj is selected second
- obj = self.selected[self.options.ids[0]]
- trafo = self.selected[self.options.ids[1]]
- if obj.tagName == 'path' and trafo.tagName == 'path':
- #distil trafo into four node points
- trafo = cubicsuperpath.parsePath(trafo.attributes.getNamedItem('d').value)
- trafo = [[Point(csp[1][0],csp[1][1]) for csp in subs] for subs in trafo][0][:4]
+ #obj is selected second
+ obj = self.selected[self.options.ids[0]]
+ trafo = self.selected[self.options.ids[1]]
+ if obj.tagName == 'path' and trafo.tagName == 'path':
+ #distil trafo into four node points
+ trafo = cubicsuperpath.parsePath(trafo.attributes.getNamedItem('d').value)
+ trafo = [[Point(csp[1][0],csp[1][1]) for csp in subs] for subs in trafo][0][:4]
- #vectors pointing away from the trafo origin
- self.t1 = Segment(trafo[0],trafo[1])
- self.t2 = Segment(trafo[1],trafo[2])
- self.t3 = Segment(trafo[3],trafo[2])
- self.t4 = Segment(trafo[0],trafo[3])
+ #vectors pointing away from the trafo origin
+ self.t1 = Segment(trafo[0],trafo[1])
+ self.t2 = Segment(trafo[1],trafo[2])
+ self.t3 = Segment(trafo[3],trafo[2])
+ self.t4 = Segment(trafo[0],trafo[3])
- #query inkscape about the bounding box of obj
- self.q = {'x':0,'y':0,'width':0,'height':0}
- file = self.args[-1]
- id = self.options.ids[0]
- for query in self.q.keys():
- f = os.popen("inkscape --query-%s --query-id=%s %s" % (query,id,file))
- 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)
- #Flip inkscapes transposed renderer coords
- self.q['y'] = docheight - self.q['y'] - self.q['height']
+ #query inkscape about the bounding box of obj
+ self.q = {'x':0,'y':0,'width':0,'height':0}
+ file = self.args[-1]
+ id = self.options.ids[0]
+ for query in self.q.keys():
+ f = os.popen("inkscape --query-%s --query-id=%s %s" % (query,id,file))
+ 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)
+ #Flip inkscapes transposed renderer coords
+ self.q['y'] = docheight - self.q['y'] - self.q['height']
- #process path
- d = obj.attributes.getNamedItem('d')
- p = cubicsuperpath.parsePath(d.value)
- for subs in p:
- for csp in subs:
- csp[0] = self.trafopoint(csp[0])
- csp[1] = self.trafopoint(csp[1])
- csp[2] = self.trafopoint(csp[2])
- d.value = cubicsuperpath.formatPath(p)
+ #process path
+ d = obj.attributes.getNamedItem('d')
+ p = cubicsuperpath.parsePath(d.value)
+ for subs in p:
+ for csp in subs:
+ csp[0] = self.trafopoint(csp[0])
+ csp[1] = self.trafopoint(csp[1])
+ csp[2] = self.trafopoint(csp[2])
+ d.value = cubicsuperpath.formatPath(p)
def trafopoint(self,(x,y)):
#Transform algorithm thanks to Jose Hevia (freon)
return [p['x'],p['y']]
e = Project()
-e.affect()
+e.affect()
\ No newline at end of file