Skip to content

Commit 5c80058

Browse files
feat: Turtle Reflection Examples ( Fixes #162 )
1 parent d1f674d commit 5c80058

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Commands/Get-Turtle.ps1

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ function Get-Turtle {
6464
.EXAMPLE
6565
# Let's make a triangle by multiplying steps
6666
turtle ('forward', 10, 'rotate', 120 * 3)
67+
.EXAMPLE
68+
# We can also write this with a polygon
69+
turtle polygon 10 3
6770
.EXAMPLE
6871
# Let's make a series of polygons, decreasing in size
6972
turtle polygon 10 6 polygon 10 5 polygon 10 4
@@ -87,6 +90,12 @@ function Get-Turtle {
8790
$sideCount
8891
}
8992
)
93+
.EXAMPLE
94+
# We can reflect a shape by drawing it with a negative number
95+
turtle polygon 42 3 polygon -42 3
96+
.EXAMPLE
97+
# We can change the angle of reflection by rotating first
98+
turtle rotate 60 polygon 42 3 polygon -42 3
9099
.EXAMPLE
91100
# We can morph any N shapes with the same number of points.
92101
turtle square 42 morph @(
@@ -95,14 +104,23 @@ function Get-Turtle {
95104
turtle square 42
96105
)
97106
.EXAMPLE
98-
# This animates the path of the turtle.
107+
# Reflections always have the same number of points.
108+
#
109+
# Morphing a shape into its reflection will zoom out, flip, and zoom back in.
110+
turtle polygon 42 6 morph @(
111+
turtle polygon -42 6
112+
turtle polygon 42 6
113+
turtle polygon -42 6
114+
)
115+
.EXAMPLE
99116
# If we want to morph a smaller shape into a bigger shape,
100-
# we can duplicate more lines
117+
#
118+
# we can duplicate lines
101119
turtle polygon 21 6 morph @(
102120
turtle @('forward', 21,'backward', 21 * 3)
103121
turtle polygon 21 6
104122
turtle @('forward', 21,'backward', 21 * 3)
105-
)
123+
)
106124
.EXAMPLE
107125
# We can repeat steps by multiplying arrays.
108126
# Lets repeat a hexagon three times with a rotation
@@ -304,6 +322,9 @@ function Get-Turtle {
304322
.EXAMPLE
305323
# The SierpinskiTriangle is a Fractal classic
306324
turtle SierpinskiTriangle 42 4
325+
.EXAMPLE
326+
# Let's draw two reflected Sierpinski Triangles
327+
turtle rotate 60 SierpinskiTriangle 42 4 SierpinskiTriangle -42 4
307328
.EXAMPLE
308329
# We can draw a 'Sierpinski Snowflake' with multiple Sierpinski Triangles.
309330
turtle @('rotate', 30, 'SierpinskiTriangle',42,4 * 12)

0 commit comments

Comments
 (0)