Commit d95b0588 authored by Thomas Holder's avatar Thomas Holder

extensions 2to3: tuple_params

parent 13d4f99f
......@@ -27,7 +27,9 @@ import cubicsuperpath, simplestyle, copy, math, re, bezmisc
def numsegs(csp):
return sum([len(p)-1 for p in csp])
def tpoint((x1,y1), (x2,y2), t = 0.5):
def tpoint(_x1_y1, _x2_y2, t = 0.5):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
return [x1+t*(x2-x1),y1+t*(y2-y1)]
def cspbezsplit(sp1, sp2, t = 0.5):
m1=tpoint(sp1[1],sp1[2],t)
......
......@@ -55,8 +55,9 @@ def rootWrapper(a,b,c,d):
return 1.0*(-d/c),
return ()
def bezierparameterize(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3))):
def bezierparameterize(xxx_todo_changeme):
#parametric bezier
((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)) = xxx_todo_changeme
x0=bx0
y0=by0
cx=3*(bx1-x0)
......@@ -69,8 +70,10 @@ def bezierparameterize(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3))):
return ax,ay,bx,by,cx,cy,x0,y0
#ax,ay,bx,by,cx,cy,x0,y0=bezierparameterize(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)))
def linebezierintersect(((lx1,ly1),(lx2,ly2)),((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3))):
def linebezierintersect(xxx_todo_changeme1, xxx_todo_changeme2):
#parametric line
((lx1,ly1),(lx2,ly2)) = xxx_todo_changeme1
((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)) = xxx_todo_changeme2
dd=lx1
cc=lx2-lx1
bb=ly1
......@@ -99,19 +102,23 @@ def linebezierintersect(((lx1,ly1),(lx2,ly2)),((bx0,by0),(bx1,by1),(bx2,by2),(bx
retval.append(bezierpointatt(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)),i))
return retval
def bezierpointatt(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)),t):
def bezierpointatt(xxx_todo_changeme3,t):
((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)) = xxx_todo_changeme3
ax,ay,bx,by,cx,cy,x0,y0=bezierparameterize(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)))
x=ax*(t**3)+bx*(t**2)+cx*t+x0
y=ay*(t**3)+by*(t**2)+cy*t+y0
return x,y
def bezierslopeatt(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)),t):
def bezierslopeatt(xxx_todo_changeme4,t):
((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)) = xxx_todo_changeme4
ax,ay,bx,by,cx,cy,x0,y0=bezierparameterize(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)))
dx=3*ax*(t**2)+2*bx*t+cx
dy=3*ay*(t**2)+2*by*t+cy
return dx,dy
def beziertatslope(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)),(dy,dx)):
def beziertatslope(xxx_todo_changeme5, xxx_todo_changeme6):
((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)) = xxx_todo_changeme5
(dy,dx) = xxx_todo_changeme6
ax,ay,bx,by,cx,cy,x0,y0=bezierparameterize(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)))
#quadratic coefficents of slope formula
if dx:
......@@ -136,9 +143,12 @@ def beziertatslope(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)),(dy,dx)):
retval.append(i)
return retval
def tpoint((x1,y1),(x2,y2),t):
def tpoint(_x1_y1, _x2_y2, t):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
return x1+t*(x2-x1),y1+t*(y2-y1)
def beziersplitatt(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)),t):
def beziersplitatt(xxx_todo_changeme9,t):
((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)) = xxx_todo_changeme9
m1=tpoint((bx0,by0),(bx1,by1),t)
m2=tpoint((bx1,by1),(bx2,by2),t)
m3=tpoint((bx2,by2),(bx3,by3),t)
......@@ -167,7 +177,9 @@ Jens Gravesen <gravesen@mat.dth.dk>
mat-report no. 1992-10, Mathematical Institute, The Technical
University of Denmark.
'''
def pointdistance((x1,y1),(x2,y2)):
def pointdistance(_x1_y1, _x2_y2):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
return math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))
def Gravesen_addifclose(b, len, error = 0.001):
box = 0
......@@ -214,13 +226,15 @@ def Simpson(f, a, b, n_limit, tolerance):
#print multiplier, endsum, interval, asum, bsum, est1, est0
return est1
def bezierlengthSimpson(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)), tolerance = 0.001):
def bezierlengthSimpson(xxx_todo_changeme12, tolerance = 0.001):
((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)) = xxx_todo_changeme12
global balfax,balfbx,balfcx,balfay,balfby,balfcy
ax,ay,bx,by,cx,cy,x0,y0=bezierparameterize(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)))
balfax,balfbx,balfcx,balfay,balfby,balfcy = 3*ax,2*bx,cx,3*ay,2*by,cy
return Simpson(balf, 0.0, 1.0, 4096, tolerance)
def beziertatlength(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)), l = 0.5, tolerance = 0.001):
def beziertatlength(xxx_todo_changeme13, l = 0.5, tolerance = 0.001):
((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)) = xxx_todo_changeme13
global balfax,balfbx,balfcx,balfay,balfby,balfcy
ax,ay,bx,by,cx,cy,x0,y0=bezierparameterize(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)))
balfax,balfbx,balfcx,balfay,balfby,balfcy = 3*ax,2*bx,cx,3*ay,2*by,cy
......
......@@ -26,7 +26,9 @@ import cubicsuperpath
import bezmisc
import simplestyle
def tpoint((x1,y1), (x2,y2), t = 0.5):
def tpoint(_x1_y1, _x2_y2, t = 0.5):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
return [x1+t*(x2-x1),y1+t*(y2-y1)]
def cspbezsplit(sp1, sp2, t = 0.5):
m1=tpoint(sp1[1],sp1[2],t)
......
......@@ -2,7 +2,8 @@
from bezmisc import *
from ffgeom import *
def maxdist(((p0x,p0y),(p1x,p1y),(p2x,p2y),(p3x,p3y))):
def maxdist(xxx_todo_changeme):
((p0x,p0y),(p1x,p1y),(p2x,p2y),(p3x,p3y)) = xxx_todo_changeme
p0 = Point(p0x,p0y)
p1 = Point(p1x,p1y)
p2 = Point(p2x,p2y)
......
......@@ -70,7 +70,9 @@ def draw_SVG_tri(vert_mat, params, style, name, parent):
inkex.etree.SubElement(parent, inkex.addNS('path','svg'), tri_attribs )
#draw an SVG line segment between the given (raw) points
def draw_SVG_line( (x1, y1), (x2, y2), style, name, parent):
def draw_SVG_line(_x1_y1, _x2_y2, style, name, parent):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
line_style = { 'stroke': style.l_col, 'stroke-width':str(style.l_th), 'fill': style.l_fill }
line_attribs = {'style':simplestyle.formatStyle(line_style),
inkex.addNS('label','inkscape'):name,
......@@ -85,10 +87,14 @@ def draw_vertex_lines( vert_mat, params, width, name, parent):
#MATHEMATICAL ROUTINES
def distance( (x0,y0),(x1,y1)):#find the pythagorean distance
def distance(_x0_y0, _x1_y1):#find the pythagorean distance
(x0, y0) = _x0_y0
(x1, y1) = _x1_y1
return sqrt( (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1) )
def vector_from_to( (x0,y0),(x1,y1) ):#get the vector from (x0,y0) to (x1,y1)
def vector_from_to(_x0_y0, _x1_y1 ):#get the vector from (x0,y0) to (x1,y1)
(x0, y0) = _x0_y0
(x1, y1) = _x1_y1
return (x1-x0, y1-y0)
def get_cartesian_pt( t, p):#get the cartesian coordinates from a trilinear set
......@@ -97,7 +103,8 @@ def get_cartesian_pt( t, p):#get the cartesian coordinates from a trilinear set
c2 = p[0][2]*t[2]/denom
return ( c1*p[2][1][0]+c2*p[2][0][0], c1*p[2][1][1]+c2*p[2][0][1] )
def get_cartesian_tri( ((t11,t12,t13),(t21,t22,t23),(t31,t32,t33)), params):#get the cartesian points from a trilinear vertex matrix
def get_cartesian_tri(xxx_todo_changeme6, params):#get the cartesian points from a trilinear vertex matrix
((t11,t12,t13),(t21,t22,t23),(t31,t32,t33)) = xxx_todo_changeme6
p1=get_cartesian_pt( (t11,t12,t13), params )
p2=get_cartesian_pt( (t21,t22,t23), params )
p3=get_cartesian_pt( (t31,t32,t33), params )
......
......@@ -49,7 +49,9 @@ except:
inkex.errormsg(_("Failed to import the numpy or numpy.linalg modules. These modules are required by this extension. Please install them and try again."))
inkex.sys.exit()
def pointdistance((x1,y1),(x2,y2)):
def pointdistance(_x1_y1, _x2_y2):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
return math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))
def get_fit(u, csp, col):
......
......@@ -99,7 +99,8 @@ except:
exit()
def bezierslopeatt(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)),t):
def bezierslopeatt(xxx_todo_changeme20,t):
((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)) = xxx_todo_changeme20
ax,ay,bx,by,cx,cy,x0,y0=bezmisc.bezierparameterize(((bx0,by0),(bx1,by1),(bx2,by2),(bx3,by3)))
dx=3*ax*(t**2)+2*bx*t+cx
dy=3*ay*(t**2)+2*by*t+cy
......@@ -1349,7 +1350,9 @@ def bounds_intersect(a, b) :
return not ( (a[0]>b[2]) or (b[0]>a[2]) or (a[1]>b[3]) or (b[1]>a[3]) )
def tpoint((x1,y1),(x2,y2),t):
def tpoint(_x1_y1, _x2_y2, t):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
return [x1+t*(x2-x1),y1+t*(y2-y1)]
......@@ -1383,7 +1386,8 @@ def bez_normalized_slope(bez,t):
### Some vector functions
################################################################################
def normalize((x,y)) :
def normalize(_x_y) :
(x, y) = _x_y
l = math.sqrt(x**2+y**2)
if l == 0 : return [0.,0.]
else : return [x/l, y/l]
......@@ -5189,7 +5193,7 @@ class Gcodetools(inkex.Effect):
eye_dist = 100 #3D constant. Try varying it for your eyes
def bisect((nx1,ny1),(nx2,ny2)) :
def bisect(_nx1_ny1, _nx2_ny2) :
"""LT Find angle bisecting the normals n1 and n2
Parameters: Normalised normals
......@@ -5199,6 +5203,8 @@ class Gcodetools(inkex.Effect):
Note that bisect(n1,n2) and bisect(n2,n1) give opposite sinBis2 results
If sinturn is less than the user's requested angle tolerance, I return 0
"""
(nx1, ny1) = _nx1_ny1
(nx2, ny2) = _nx2_ny2
#We can get absolute value of cos(bisector vector)
#Note: Need to use max in case of rounding errors
cosBis = math.sqrt(max(0,(1.0+nx1*nx2-ny1*ny2)/2.0))
......@@ -5219,7 +5225,7 @@ class Gcodetools(inkex.Effect):
return (cosBis/costurn,sinBis/costurn, sinturn)
#end bisect
def get_radius_to_line((x1,y1),(nx1,ny1), (nx2,ny2),(x2,y2),(nx23,ny23),(x3,y3),(nx3,ny3)):
def get_radius_to_line(_x1_y1, _nx1_ny1, _nx2_ny2, _x2_y2, _nx23_ny23, _x3_y3, _nx3_ny3):
"""LT find biggest circle we can engrave here, if constrained by line 2-3
Parameters:
......@@ -5245,7 +5251,13 @@ class Gcodetools(inkex.Effect):
# Algorithm uses dot products of normals to find radius
# and hence coordinates of centre
"""
(x1, y1) = _x1_y1
(nx1, ny1) = _nx1_ny1
(nx2, ny2) = _nx2_ny2
(x2, y2) = _x2_y2
(nx23, ny23) = _nx23_ny23
(x3, y3) = _x3_y3
(nx3, ny3) = _nx3_ny3
global max_dist
#Start by converting coordinates to be relative to x1,y1
......@@ -5279,7 +5291,7 @@ class Gcodetools(inkex.Effect):
return min(r, max_dist)
#end of get_radius_to_line
def get_radius_to_point((x1,y1),(nx,ny), (x2,y2)):
def get_radius_to_point(_x1_y1, _nx_ny, _x2_y2):
"""LT find biggest circle we can engrave here, constrained by point x2,y2
This function can be used in three ways:
......@@ -5293,7 +5305,9 @@ class Gcodetools(inkex.Effect):
It turns out that finding a circle touching a point is harder than a circle
touching a line.
"""
(x1, y1) = _x1_y1
(nx, ny) = _nx_ny
(x2, y2) = _x2_y2
global max_dist
#Start by converting coordinates to be relative to x1,y1
......@@ -5356,7 +5370,7 @@ class Gcodetools(inkex.Effect):
return bez_divide(a,[abx,aby],[abcx,abcy],m) + bez_divide(m,[bcdx,bcdy],[cdx,cdy],d)
#end of bez_divide
def get_biggest((x1,y1),(nx,ny)):
def get_biggest(_x1_y1, _nx_ny):
"""LT Find biggest circle we can draw inside path at point x1,y1 normal nx,ny
Parameters:
......@@ -5366,6 +5380,8 @@ class Gcodetools(inkex.Effect):
tuple (j,i,r)
..where j and i are indices of limiting segment, r is radius
"""
(x1, y1) = _x1_y1
(nx, ny) = _nx_ny
global max_dist, nlLT, i, j
n1 = nlLT[j][i-1] #current node
jjmin = -1
......@@ -5414,7 +5430,7 @@ class Gcodetools(inkex.Effect):
return (jjmin,iimin,r)
#end of get_biggest
def line_divide((x0,y0),j0,i0,(x1,y1),j1,i1,(nx,ny),length):
def line_divide(_x0_y0, j0, i0, _x1_y1, j1, i1, _nx_ny, length):
"""LT recursively divide a line as much as necessary
NOTE: This function is not currently used
......@@ -5429,6 +5445,9 @@ class Gcodetools(inkex.Effect):
each a list of 3 reals: x, y coordinates, radius
"""
(x0, y0) = _x0_y0
(x1, y1) = _x1_y1
(nx, ny) = _nx_ny
global nlLT, i, j, lmin
x2=(x0+x1)/2
y2=(y0+y1)/2
......@@ -5441,12 +5460,13 @@ class Gcodetools(inkex.Effect):
return [ line_divide((x0,y0),j0,i0,(x2,y2),j2,i2,(nx,ny),length/2), line_divide((x2,y2),j2,i2,(x1,y1),j1,i1,(nx,ny),length/2)]
#end of line_divide()
def save_point((x,y),w,i,j,ii,jj):
def save_point(_x_y,w,i,j,ii,jj):
"""LT Save this point and delete previous one if linear
The point is, we generate tons of points but many may be in a straight 3D line.
There is no benefit in saving the imtermediate points.
"""
(x, y) = _x_y
global wl, cspm
x=round(x,4) #round to 4 decimals
y=round(y,4) #round to 4 decimals
......@@ -5474,13 +5494,15 @@ class Gcodetools(inkex.Effect):
wl+=[w]
#end of save_point
def draw_point((x0,y0),(x,y),w,t):
def draw_point(_x0_y0, _x_y,w,t):
"""LT Draw this point as a circle with a 1px dot in the middle (x,y)
and a 3D line from (x0,y0) down to x,y. 3D line thickness should be t/2
Note that points that are subsequently erased as being unneeded do get
displayed, but this helps the user see the total area covered.
"""
(x0, y0) = _x0_y0
(x, y) = _x_y
global gcode_3Dleft ,gcode_3Dright
if self.options.engraving_draw_calculation_paths :
inkex.etree.SubElement( engraving_group, inkex.addNS('path','svg'),
......
......@@ -24,11 +24,15 @@ def interpcoord(v1,v2,p):
return v1+((v2-v1)*p)
def interppoints(p1,p2,p):
return [interpcoord(p1[0],p2[0],p),interpcoord(p1[1],p2[1],p)]
def pointdistance((x1,y1),(x2,y2)):
def pointdistance(_x1_y1, _x2_y2):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
return math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))
def bezlenapprx(sp1, sp2):
return pointdistance(sp1[1], sp1[2]) + pointdistance(sp1[2], sp2[0]) + pointdistance(sp2[0], sp2[1])
def tpoint((x1,y1), (x2,y2), t = 0.5):
def tpoint(_x1_y1, _x2_y2, t = 0.5):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
return [x1+t*(x2-x1),y1+t*(y2-y1)]
def cspbezsplit(sp1, sp2, t = 0.5):
m1=tpoint(sp1[1],sp1[2],t)
......
......@@ -19,7 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
'''
import random, math, inkex, cubicsuperpath
def randomize((x, y), rx, ry, dist):
def randomize(_x_y, rx, ry, dist):
(x, y) = _x_y
if dist == "Gaussian":
r1 = random.gauss(0.0,rx)
......
......@@ -73,11 +73,15 @@ def interpcoord(v1,v2,p):
return v1+((v2-v1)*p)
def interppoints(p1,p2,p):
return [interpcoord(p1[0],p2[0],p),interpcoord(p1[1],p2[1],p)]
def pointdistance((x1,y1),(x2,y2)):
def pointdistance(_x1_y1, _x2_y2):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
return math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))
def bezlenapprx(sp1, sp2):
return pointdistance(sp1[1], sp1[2]) + pointdistance(sp1[2], sp2[0]) + pointdistance(sp2[0], sp2[1])
def tpoint((x1,y1), (x2,y2), t = 0.5):
def tpoint(_x1_y1, _x2_y2, t = 0.5):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
return [x1+t*(x2-x1),y1+t*(y2-y1)]
def cspbezsplit(sp1, sp2, t = 0.5):
m1=tpoint(sp1[1],sp1[2],t)
......
......@@ -30,7 +30,8 @@ class Motion(inkex.Effect):
dest="magnitude", default=100.0,
help="magnitude of the motion vector")
def makeface(self,last,(cmd, params)):
def makeface(self,last, xxx_todo_changeme):
(cmd, params) = xxx_todo_changeme
a = []
a.append(['M',last[:]])
a.append([cmd, params[:]])
......
......@@ -139,7 +139,8 @@ def get_obj_data(obj, name):
#RENDERING AND SVG OUTPUT FUNCTIONS
def draw_SVG_dot((cx, cy), st, name, parent):
def draw_SVG_dot(_cx_cy, st, name, parent):
(cx, cy) = _cx_cy
style = { 'stroke': '#000000', 'stroke-width':str(st.th), 'fill': st.fill, 'stroke-opacity':st.s_opac, 'fill-opacity':st.f_opac}
circ_attribs = {'style':simplestyle.formatStyle(style),
inkex.addNS('label','inkscape'):name,
......@@ -147,7 +148,9 @@ def draw_SVG_dot((cx, cy), st, name, parent):
'cx':str(cx), 'cy':str(-cy)}
inkex.etree.SubElement(parent, inkex.addNS('circle','svg'), circ_attribs )
def draw_SVG_line((x1, y1),(x2, y2), st, name, parent):
def draw_SVG_line(_x1_y1, _x2_y2, st, name, parent):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
style = { 'stroke': '#000000', 'stroke-width':str(st.th), 'stroke-linecap':st.linecap}
line_attribs = {'style':simplestyle.formatStyle(style),
inkex.addNS('label','inkscape'):name,
......@@ -186,8 +189,9 @@ def draw_faces( faces_data, pts, obj, shading, fill_col,st, parent):
face_no = face[3]#the number of the face to draw
draw_SVG_poly(pts, obj.fce[ face_no ], st, 'Face:'+str(face_no), parent)
def get_darkened_colour( (r,g,b), factor):
def get_darkened_colour(_r_g_b, factor):
#return a hex triplet of colour, reduced in lightness proportionally to a value between 0 and 1
(r, g, b) = _r_g_b
return '#' + "%02X" % floor( factor*r ) \
+ "%02X" % floor( factor*g ) \
+ "%02X" % floor( factor*b ) #make the colour string
......
......@@ -55,7 +55,8 @@ class pTurtle:
def clear(self):
self.clean()
self.home()
def setpos(self,(x,y)):
def setpos(self, _x_y):
(x, y) = _x_y
if self.__new:
self.__path += "M"+",".join([str(i) for i in self.__pos])
self.__new = False
......@@ -68,7 +69,8 @@ class pTurtle:
self.__heading = deg
def getheading(self):
return self.__heading
def sethome(self,(x,y)):
def sethome(self, _x_y):
(x, y) = _x_y
self.__home = [x, y]
def getPath(self):
return self.__path
......
......@@ -95,8 +95,9 @@ symbols = {
#=====================================================================
#create a 2d list corresponding to the 1's and 0s of the DataMatrix
def encode(text, (nrow, ncol) ):
def encode(text, xxx_todo_changeme ):
#retreive the parameters of this size of DataMatrix
(nrow, ncol) = xxx_todo_changeme
data_nrow, data_ncol, reg_row, reg_col, nd, nc, inter = get_parameters( nrow, ncol )
if not ((nrow == 144) and (ncol == 144)): #we have a regular datamatrix
......@@ -510,8 +511,9 @@ def utah(array, nrow, ncol, row, col, char):
#"place_bits" fills an nrow x ncol array with the bits from the
# codewords in data.
def place_bits(data, (nrow, ncol)):
def place_bits(data, xxx_todo_changeme1):
# First, fill the array[] with invalid entries */
(nrow, ncol) = xxx_todo_changeme1
INVALID = 2
array = [[INVALID] * ncol for i in xrange(nrow)] #initialise and fill with -1's (invalid value)
# Starting in the correct location for character #1, bit 8,...
......@@ -609,7 +611,9 @@ def add_finder_pattern( array, data_nrow, data_ncol, reg_row, reg_col ):
#=====================================================================
#SVG element generation routine
def draw_SVG_square((w,h), (x,y), parent):
def draw_SVG_square(_w_h, _x_y, parent):
(w, h) = _w_h
(x, y) = _x_y
style = { 'stroke' : 'none',
'stroke-width' : '1',
......
......@@ -18,7 +18,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
'''
import math, inkex, simplepath, sys
def pointAtPercent((x1, y1), (x2, y2), percent):
def pointAtPercent(_x1_y1, _x2_y2, percent):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
percent /= 100.0
x = x1 + (percent * (x2 - x1))
y = y1 + (percent * (y2 - y1))
......
......@@ -116,7 +116,8 @@ class Project(inkex.Effect):
simpletransform.applyTransformToPath(mat, p)
path.set('d',cubicsuperpath.formatPath(p))
def trafopoint(self,(x,y)):
def trafopoint(self, _x_y):
(x, y) = _x_y
#Transform algorithm thanks to Jose Hevia (freon)
vector = Segment(Point(self.q['x'],self.q['y']),Point(x,y))
xratio = abs(vector.delta_x())/self.q['width']
......
......@@ -37,7 +37,11 @@ import simplestyle, sys
from simpletransform import computePointInNode
from math import *
def draw_SVG_tri( (x1, y1), (x2, y2), (x3, y3), (ox,oy), width, name, parent):
def draw_SVG_tri(_x1_y1, _x2_y2, _x3_y3, _ox_oy, width, name, parent):
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
(x3, y3) = _x3_y3
(ox, oy) = _ox_oy
style = { 'stroke': '#000000', 'stroke-width':str(width), 'fill': 'none' }
tri_attribs = {'style':simplestyle.formatStyle(style),
inkex.addNS('label','inkscape'):name,
......@@ -63,7 +67,9 @@ def pt_on_circ(radius, angle): #return the x,y coordinate of the polar coordinat
y = radius * sin(angle)
return [x, y]
def v_add( (x1,y1),(x2,y2) ):#add an offset to coordinates
def v_add(_x1_y1, _x2_y2):#add an offset to coordinates
(x1, y1) = _x1_y1
(x2, y2) = _x2_y2
return [x1+x2, y1+y2]
def is_valid_tri_from_sides(a,b,c):#check whether triangle with sides a,b,c is valid
......
......@@ -63,7 +63,9 @@ from simpletransform import computePointInNode
#SVG OUTPUT FUNCTIONS ================================================
def draw_SVG_ellipse((rx, ry), (cx, cy), width, parent, start_end=(0,2*pi),transform='' ):
def draw_SVG_ellipse(_rx_ry, _cx_cy, width, parent, start_end=(0,2*pi),transform='' ):
(rx, ry) = _rx_ry
(cx, cy) = _cx_cy
style = { 'stroke' : '#000000',
'stroke-width' : str(width),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment