From: <joergl@us...>  20060518 20:40:22

Revision: 2722 Author: joergl Date: 20060518 13:40:07 0700 (Thu, 18 May 2006) ViewCVS: http://svn.sourceforge.net/pyx/?rev=2722&view=rev Log Message:  move ellipse from drawing to drawing2 Modified Paths:  trunk/pyx/examples/drawing/INDEX trunk/pyx/examples/drawing2/INDEX Added Paths:  trunk/pyx/examples/drawing2/ellipse.py trunk/pyx/examples/drawing2/ellipse.txt Removed Paths:  trunk/pyx/examples/drawing/ellipse.py trunk/pyx/examples/drawing/ellipse.txt Modified: trunk/pyx/examples/drawing/INDEX ===================================================================  trunk/pyx/examples/drawing/INDEX 20060518 17:42:58 UTC (rev 2721) +++ trunk/pyx/examples/drawing/INDEX 20060518 20:40:07 UTC (rev 2722) @@ 2,5 +2,4 @@ pathitem style strokefill ellipse arrow Deleted: trunk/pyx/examples/drawing/ellipse.py ===================================================================  trunk/pyx/examples/drawing/ellipse.py 20060518 17:42:58 UTC (rev 2721) +++ trunk/pyx/examples/drawing/ellipse.py 20060518 20:40:07 UTC (rev 2722) @@ 1,8 +0,0 @@ from pyx import *  c = canvas.canvas() c.stroke(path.circle(0, 0, 1), [trafo.scale(sx=2, sy=1.5),  trafo.rotate(45),  trafo.translate(1, 0)]) c.writeEPSfile("ellipse") c.writePDFfile("ellipse") Deleted: trunk/pyx/examples/drawing/ellipse.txt ===================================================================  trunk/pyx/examples/drawing/ellipse.txt 20060518 17:42:58 UTC (rev 2721) +++ trunk/pyx/examples/drawing/ellipse.txt 20060518 20:40:07 UTC (rev 2722) @@ 1,35 +0,0 @@ Applying transformations when drawing a path: Creating an ellipse  PyX does not directly provide a path corresponding to an ellipse. This example shows how to draw an ellipse using affine transformations. ...  In order to create an ellipse, we best start from a unit circle centered around the point of origin of the coordinate system. When stroking this circle on the canvas, we tell PyX to apply a couple of affine transformations first. These affine transformations are contained in the `trafo` module. We first use `trafo.scale` to apply a nonuniform scaling, namely by a factor of 2 in xdirection and a factor of 1.5 in ydirection. Doing so, we define the two principle axes of the ellipse. In a next step, we rotate with `trafo.rotate` the ellipse by an angle of 45 degrees in the mathematical positive direction, i.e. counterclockwise. Last, we shift the origin of the ellipse to the desired point by applying a `trafo.translate` operation.  ! Note that the order of the transformations matters. If you, for instance, would first translate the ellipse, the later scaling would also affect the distance by which you have shifted the ellipse. PyX applies the transformations one after the other, from left to right, so the example shown above does the correct thing.  ! You can also treat transformations as mathematical objects (they are represented by twodimensional matrices together with an offset vector) and multiply them using the `*` operator. Note, however, that mathematically, transformations are applied from right to left, such that the above example would need to be written as   c.stroke(path.circle(0, 0, 1), [trafo.translate(1,0) * trafo.rotate(45) * trafo.scale(sx=2, sy=1.5)])  ! PyX also provides some convenience methods for applying certain transformations with a given point as the origin. These allow one to write the example in yet another form   c.stroke(path.circle(1, 0, 1), [trafo.scale(sx=2, sy=1.5, x=1, y=0), trafo.rotate(45, x=1, y=0)])  where we have started already from a circle centered around the desired point 1,0. Modified: trunk/pyx/examples/drawing2/INDEX ===================================================================  trunk/pyx/examples/drawing2/INDEX 20060518 17:42:58 UTC (rev 2721) +++ trunk/pyx/examples/drawing2/INDEX 20060518 20:40:07 UTC (rev 2722) @@ 1,3 +1,4 @@ +ellipse smoothed parallel clipping Copied: trunk/pyx/examples/drawing2/ellipse.py (from rev 2721, trunk/pyx/examples/drawing/ellipse.py) ===================================================================  trunk/pyx/examples/drawing2/ellipse.py (rev 0) +++ trunk/pyx/examples/drawing2/ellipse.py 20060518 20:40:07 UTC (rev 2722) @@ 0,0 +1,8 @@ +from pyx import * + +c = canvas.canvas() +c.stroke(path.circle(0, 0, 1), [trafo.scale(sx=2, sy=1.5), + trafo.rotate(45), + trafo.translate(1, 0)]) +c.writeEPSfile("ellipse") +c.writePDFfile("ellipse") Copied: trunk/pyx/examples/drawing2/ellipse.txt (from rev 2721, trunk/pyx/examples/drawing/ellipse.txt) ===================================================================  trunk/pyx/examples/drawing2/ellipse.txt (rev 0) +++ trunk/pyx/examples/drawing2/ellipse.txt 20060518 20:40:07 UTC (rev 2722) @@ 0,0 +1,35 @@ +Applying transformations when drawing a path: Creating an ellipse + +PyX does not directly provide a path corresponding to an ellipse. This example +shows how to draw an ellipse using affine transformations. ... + +In order to create an ellipse, we best start from a unit circle centered around +the point of origin of the coordinate system. When stroking this circle on the +canvas, we tell PyX to apply a couple of affine transformations first. These +affine transformations are contained in the `trafo` module. We first use +`trafo.scale` to apply a nonuniform scaling, namely by a factor of 2 in +xdirection and a factor of 1.5 in ydirection. Doing so, we define the two +principle axes of the ellipse. In a next step, we rotate with `trafo.rotate` +the ellipse by an angle of 45 degrees in the mathematical positive direction, +i.e. counterclockwise. Last, we shift the origin of the ellipse to the desired +point by applying a `trafo.translate` operation. + +! Note that the order of the transformations matters. If you, for instance, would +first translate the ellipse, the later scaling would also affect the distance +by which you have shifted the ellipse. PyX applies the transformations one after +the other, from left to right, so the example shown above does the correct thing. + +! You can also treat transformations as mathematical objects (they +are represented by twodimensional matrices together with an offset vector) and +multiply them using the `*` operator. Note, however, that mathematically, transformations +are applied from right to left, such that the above example would need to be written as + + c.stroke(path.circle(0, 0, 1), [trafo.translate(1,0) * trafo.rotate(45) * trafo.scale(sx=2, sy=1.5)]) + +! PyX also provides some convenience methods for applying certain +transformations with a given point as the origin. These allow one to write the +example in yet another form + + c.stroke(path.circle(1, 0, 1), [trafo.scale(sx=2, sy=1.5, x=1, y=0), trafo.rotate(45, x=1, y=0)]) + +where we have started already from a circle centered around the desired point 1,0. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. 