|
@@ -1,5 +1,12 @@
|
|
|
======= Basic Shapes =======
|
|
======= Basic Shapes =======
|
|
|
|
|
|
|
|
|
|
+This section presents many of the basic shapes in Pysketcher:
|
|
|
|
|
+`Axis`, `Distance_wText`, `Rectangle`, Triangle`, `Arc`,
|
|
|
|
|
+`Spring`, `Dashpot`, and `Wavy`.
|
|
|
|
|
+Each shape is demonstrated with a figure and a
|
|
|
|
|
+unit test that shows how the figure is constructed in Python code.
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
===== Axis =====
|
|
===== Axis =====
|
|
|
|
|
|
|
|
The `Axis` object gives the possibility draw a single axis to
|
|
The `Axis` object gives the possibility draw a single axis to
|
|
@@ -7,8 +14,14 @@ notify a coordinate system. Here is an example where we
|
|
|
draw $x$ and $y$ axis of three coordinate systems of different
|
|
draw $x$ and $y$ axis of three coordinate systems of different
|
|
|
rotation:
|
|
rotation:
|
|
|
|
|
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+
|
|
|
FIGURE: [fig-tut/Axis, width=500 frac=0.7]
|
|
FIGURE: [fig-tut/Axis, width=500 frac=0.7]
|
|
|
|
|
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+
|
|
|
The corresponding code looks like this:
|
|
The corresponding code looks like this:
|
|
|
|
|
|
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Axis@drawing_tool.savefig\('tmp_Axis'\)
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Axis@drawing_tool.savefig\('tmp_Axis'\)
|
|
@@ -20,8 +33,16 @@ a distance in a sketch, with an additional text in the middle of the arrow.
|
|
|
|
|
|
|
|
The figure
|
|
The figure
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+
|
|
|
FIGURE: [fig-tut/Distance_wText, width=500 frac=0.7]
|
|
FIGURE: [fig-tut/Distance_wText, width=500 frac=0.7]
|
|
|
|
|
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
was produced by this code:
|
|
was produced by this code:
|
|
|
|
|
|
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Distance_wText@drawing_tool.savefig\('tmp_Distance
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Distance_wText@drawing_tool.savefig\('tmp_Distance
|
|
@@ -34,6 +55,9 @@ the appearance of the text that goes with the distance arrow.
|
|
|
|
|
|
|
|
FIGURE: [fig-tut/Rectangle, width=500 frac=0.7]
|
|
FIGURE: [fig-tut/Rectangle, width=500 frac=0.7]
|
|
|
|
|
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+
|
|
|
The above figure can be produced by the following code.
|
|
The above figure can be produced by the following code.
|
|
|
|
|
|
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Rectangle@drawing_tool.savefig\('tmp_Rectangle
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Rectangle@drawing_tool.savefig\('tmp_Rectangle
|
|
@@ -45,6 +69,9 @@ important argument in the construction of a shape.
|
|
|
|
|
|
|
|
FIGURE: [fig-tut/Triangle, width=500 frac=0.7]
|
|
FIGURE: [fig-tut/Triangle, width=500 frac=0.7]
|
|
|
|
|
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+
|
|
|
The code below produces the figure.
|
|
The code below produces the figure.
|
|
|
|
|
|
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Triangle@drawing_tool.savefig\('tmp_Triangle
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Triangle@drawing_tool.savefig\('tmp_Triangle
|
|
@@ -55,11 +82,12 @@ to the location of the p1, p2, and even p3 texts.
|
|
|
|
|
|
|
|
===== Arc =====
|
|
===== Arc =====
|
|
|
|
|
|
|
|
-An arc like
|
|
|
|
|
-
|
|
|
|
|
FIGURE: [fig-tut/Arc, width=400 frac=0.5]
|
|
FIGURE: [fig-tut/Arc, width=400 frac=0.5]
|
|
|
|
|
|
|
|
-is produced by
|
|
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+
|
|
|
|
|
+An arc like the one above is produced by
|
|
|
|
|
|
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Arc@drawing_tool.savefig\('tmp_Arc
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Arc@drawing_tool.savefig\('tmp_Arc
|
|
|
|
|
|
|
@@ -67,6 +95,9 @@ is produced by
|
|
|
|
|
|
|
|
FIGURE: [fig-tut/Spring, width=800 frac=1]
|
|
FIGURE: [fig-tut/Spring, width=800 frac=1]
|
|
|
|
|
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+
|
|
|
The code for making this spring is
|
|
The code for making this spring is
|
|
|
|
|
|
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Spring@drawing_tool.savefig\('tmp_Spring
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Spring@drawing_tool.savefig\('tmp_Spring
|
|
@@ -75,6 +106,9 @@ The code for making this spring is
|
|
|
|
|
|
|
|
FIGURE: [fig-tut/Dashpot, width=600 frac=0.8]
|
|
FIGURE: [fig-tut/Dashpot, width=600 frac=0.8]
|
|
|
|
|
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+
|
|
|
This dashpot is produced by
|
|
This dashpot is produced by
|
|
|
|
|
|
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Dashpot@drawing_tool.savefig\('tmp_Dashpot
|
|
@@@CODE ../../../pysketcher/shapes.py fromto: def test_Dashpot@drawing_tool.savefig\('tmp_Dashpot
|
|
@@ -88,8 +122,14 @@ Looks strange. Fix x axis.
|
|
|
The `StochasticWavyCurve` object offers three precomputed
|
|
The `StochasticWavyCurve` object offers three precomputed
|
|
|
graphics that have a random variation:
|
|
graphics that have a random variation:
|
|
|
|
|
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+
|
|
|
FIGURE: [fig-tut/StochasticWavyCurve.png, width=600 frac=1]
|
|
FIGURE: [fig-tut/StochasticWavyCurve.png, width=600 frac=1]
|
|
|
|
|
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+<linebreak>
|
|
|
|
|
+
|
|
|
The usage is simple. The construction
|
|
The usage is simple. The construction
|
|
|
|
|
|
|
|
!bc pycod
|
|
!bc pycod
|