[PyX-checkins] SF.net SVN: pyx: [2619] trunk/pyx/examples/path/knot.py From: - 2006-04-27 07:45 ```Revision: 2619 Author: m-schindler Date: 2006-04-27 00:45:19 -0700 (Thu, 27 Apr 2006) ViewCVS: http://svn.sourceforge.net/pyx/?rev=2619&view=rev Log Message: ----------- improve the shape and overlapping of the parts of the knot Modified Paths: -------------- trunk/pyx/examples/path/knot.py Modified: trunk/pyx/examples/path/knot.py =================================================================== --- trunk/pyx/examples/path/knot.py 2006-04-27 07:10:21 UTC (rev 2618) +++ trunk/pyx/examples/path/knot.py 2006-04-27 07:45:19 UTC (rev 2619) @@ -25,14 +25,18 @@ path.curveto(pts[8][0],pts[8][1],pts[9][0],pts[9][1],pts[10][0],pts[10][1]), path.lineto(*(pts[11])) ) # We smooth this curve a little because we used curveto together with lineto -seam = deformer.smoothed(0.2).deform(seam) +seam = deformer.smoothed(0.6).deform(seam) # The ropes, when drawn later, will have to overlap in a very specific way. # We need to split them at appropriate points. # This gives a list of segments for the middle curve l = seam.arclen() -seam_segs = seam.split([0.28*l, 0.42*l, 0.58*l, 0.72*l]) +eps = 0.002*l +lenghts = [eps, 0.28*l, 0.42*l, 0.58*l, 0.72*l, l-eps] +seam_segs = [] +for i in range(len(lenghts)-1): + seam_segs.append(seam.split([lenghts[i]-eps, lenghts[i+1]+eps])[1]) # For each segment two shifted paths build the boundaries of each rope This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [PyX-checkins] SF.net SVN: pyx: [2667] trunk/pyx/examples/path/knot.py From: - 2006-05-17 08:41 ```Revision: 2667 Author: wobsta Date: 2006-05-17 01:41:10 -0700 (Wed, 17 May 2006) ViewCVS: http://svn.sourceforge.net/pyx/?rev=2667&view=rev Log Message: ----------- use a single split call (consider this as a suggestion) Modified Paths: -------------- trunk/pyx/examples/path/knot.py Modified: trunk/pyx/examples/path/knot.py =================================================================== --- trunk/pyx/examples/path/knot.py 2006-05-17 08:39:55 UTC (rev 2666) +++ trunk/pyx/examples/path/knot.py 2006-05-17 08:41:10 UTC (rev 2667) @@ -29,11 +29,11 @@ # The ropes, when drawn later, will have to overlap in a very specific way. l = seam.arclen() -eps = 0.002*l -lenghts = [eps, 0.28*l, 0.42*l, 0.58*l, 0.72*l, l-eps] -seam_segs = [] -for i in range(len(lenghts)-1): - seam_segs.append(seam.split([lenghts[i]-eps, lenghts[i+1]+eps])[1]) +epsilon = 0.002*l # small overlap between the segments +seam_segs = seam.split([0.28*l+epsilon, 0.28*l-epsilon, + 0.42*l+epsilon, 0.42*l-epsilon, + 0.58*l+epsilon, 0.58*l-epsilon, + 0.72*l+epsilon, 0.72*l-epsilon])[::2] # For each segment, two shifted paths build the boundaries of each rope ropes_segs = [] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```