## [PyX-checkins] SF.net SVN: pyx: [2689] trunk/pyx/examples/drawing

 [PyX-checkins] SF.net SVN: pyx: [2689] trunk/pyx/examples/drawing From: - 2006-05-17 16:02:30 ```Revision: 2689 Author: joergl Date: 2006-05-17 09:02:24 -0700 (Wed, 17 May 2006) ViewCVS: http://svn.sourceforge.net/pyx/?rev=2689&view=rev Log Message: ----------- really add ellipse example Added Paths: ----------- trunk/pyx/examples/drawing/ellipse.py trunk/pyx/examples/drawing/ellipse.txt Added: trunk/pyx/examples/drawing/ellipse.py =================================================================== --- trunk/pyx/examples/drawing/ellipse.py (rev 0) +++ trunk/pyx/examples/drawing/ellipse.py 2006-05-17 16:02:24 UTC (rev 2689) @@ -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") Added: trunk/pyx/examples/drawing/ellipse.txt =================================================================== --- trunk/pyx/examples/drawing/ellipse.txt (rev 0) +++ trunk/pyx/examples/drawing/ellipse.txt 2006-05-17 16:02:24 UTC (rev 2689) @@ -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 non-uniform scaling, namely by a factor of 2 in +x-direction and a factor of 1.5 in y-direction. 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. counter-clockwise. 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 two-dimensional 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. ```

 [PyX-checkins] SF.net SVN: pyx: [2689] trunk/pyx/examples/drawing From: - 2006-05-17 16:02:30 ```Revision: 2689 Author: joergl Date: 2006-05-17 09:02:24 -0700 (Wed, 17 May 2006) ViewCVS: http://svn.sourceforge.net/pyx/?rev=2689&view=rev Log Message: ----------- really add ellipse example Added Paths: ----------- trunk/pyx/examples/drawing/ellipse.py trunk/pyx/examples/drawing/ellipse.txt Added: trunk/pyx/examples/drawing/ellipse.py =================================================================== --- trunk/pyx/examples/drawing/ellipse.py (rev 0) +++ trunk/pyx/examples/drawing/ellipse.py 2006-05-17 16:02:24 UTC (rev 2689) @@ -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") Added: trunk/pyx/examples/drawing/ellipse.txt =================================================================== --- trunk/pyx/examples/drawing/ellipse.txt (rev 0) +++ trunk/pyx/examples/drawing/ellipse.txt 2006-05-17 16:02:24 UTC (rev 2689) @@ -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 non-uniform scaling, namely by a factor of 2 in +x-direction and a factor of 1.5 in y-direction. 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. counter-clockwise. 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 two-dimensional 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. ```
 [PyX-checkins] SF.net SVN: pyx: [2722] trunk/pyx/examples/drawing From: - 2006-05-18 20:40:22 ```Revision: 2722 Author: joergl Date: 2006-05-18 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 2006-05-18 17:42:58 UTC (rev 2721) +++ trunk/pyx/examples/drawing/INDEX 2006-05-18 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 2006-05-18 17:42:58 UTC (rev 2721) +++ trunk/pyx/examples/drawing/ellipse.py 2006-05-18 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 2006-05-18 17:42:58 UTC (rev 2721) +++ trunk/pyx/examples/drawing/ellipse.txt 2006-05-18 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 non-uniform scaling, namely by a factor of 2 in -x-direction and a factor of 1.5 in y-direction. 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. counter-clockwise. 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 two-dimensional 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 2006-05-18 17:42:58 UTC (rev 2721) +++ trunk/pyx/examples/drawing2/INDEX 2006-05-18 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 2006-05-18 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 2006-05-18 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 non-uniform scaling, namely by a factor of 2 in +x-direction and a factor of 1.5 in y-direction. 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. counter-clockwise. 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 two-dimensional 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. ```
 [PyX-checkins] SF.net SVN: pyx: [2777] trunk/pyx/examples/drawing From: - 2006-05-22 14:54:15 ```Revision: 2777 Author: wobsta Date: 2006-05-22 07:53:59 -0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/pyx/?rev=2777&view=rev Log Message: ----------- some adjustments to make the examples nice-looking again after the dash/rellength/linewidth adjustment Modified Paths: -------------- trunk/pyx/examples/drawing/arrow.py trunk/pyx/examples/drawing/style.py Modified: trunk/pyx/examples/drawing/arrow.py =================================================================== --- trunk/pyx/examples/drawing/arrow.py 2006-05-22 14:23:31 UTC (rev 2776) +++ trunk/pyx/examples/drawing/arrow.py 2006-05-22 14:53:59 UTC (rev 2777) @@ -1,7 +1,7 @@ from pyx import * c = canvas.canvas() -c.stroke(path.curve(0, 0, 0, 3, 2, 3, 3, 2), +c.stroke(path.curve(0, 0, 0, 4, 2, 4, 3, 3), [style.linewidth.THICK, style.linestyle.dashed, color.rgb.blue, deco.earrow([deco.stroked([color.rgb.red, style.linejoin.round]), deco.filled([color.rgb.green])], size=1)]) Modified: trunk/pyx/examples/drawing/style.py =================================================================== --- trunk/pyx/examples/drawing/style.py 2006-05-22 14:23:31 UTC (rev 2776) +++ trunk/pyx/examples/drawing/style.py 2006-05-22 14:53:59 UTC (rev 2777) @@ -2,7 +2,7 @@ c = canvas.canvas() c.stroke(path.line(0, 0, 4, 0), - [style.linewidth.THIck, style.linestyle.dashed, color.rgb.red]) + [style.linewidth.THICK, style.linestyle.dashed, color.rgb.red]) c.stroke(path.line(0, -1, 4, -1), [style.linewidth(0.2), style.linecap.round, color.rgb.green]) c.fill(path.rect(0, -3, 4, 1), [color.rgb.blue]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```