Skip to content

Commit 912d8fb

Browse files
docs: Updating samples
Spreading out code and docs
1 parent f5d7624 commit 912d8fb

File tree

1 file changed

+37
-16
lines changed

1 file changed

+37
-16
lines changed

Commands/Get-Turtle.ps1

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,14 @@ function Get-Turtle {
150150
$sideCount = (3..12 | Get-Random)
151151
turtle Flower 50 15 $sideCount 36 morph @(
152152
turtle Flower 50 10 $sideCount 72
153-
turtle rotate (Get-Random -Max 360 -Min 180) Flower 50 5 $sideCount 72
153+
turtle rotate (
154+
Get-Random -Max 360 -Min -360
155+
) Flower 50 5 $sideCount 72
154156
turtle Flower 50 10 $sideCount 72
155157
)
156158
.EXAMPLE
157-
# We can draw a pair of arcs and turn back after each one.
159+
# We can draw a pair of arcs and turn back after each one.
160+
#
158161
# We call this a 'petal'.
159162
turtle rotate -30 Petal 42 60
160163
.EXAMPLE
@@ -175,14 +178,16 @@ function Get-Turtle {
175178
$flowerAngle = 30..60 | Get-Random
176179
$AngleFactor = 2..6 | Get-Random
177180
$StepCount = 36
178-
$flowerPetals = turtle rotate (
179-
(Get-Random -Max 180) * -1
180-
) flowerPetal $radius 10 $flowerAngle $stepCount
181-
$flowerPetals2 = turtle rotate (
182-
(Get-Random -Max 180)
183-
) flowerPetal $radius (
184-
10 * $AngleFactor
185-
) $flowerAngle $stepCount
181+
$flowerPetals =
182+
turtle rotate (
183+
(Get-Random -Max 180) * -1
184+
) flowerPetal $radius 10 $flowerAngle $stepCount
185+
$flowerPetals2 =
186+
turtle rotate (
187+
(Get-Random -Max 180)
188+
) flowerPetal $radius (
189+
10 * $AngleFactor
190+
) $flowerAngle $stepCount
186191
turtle flowerPetal $radius 10 $flowerAngle $stepCount morph (
187192
$flowerPetals,
188193
$flowerPetals2,
@@ -235,30 +240,33 @@ function Get-Turtle {
235240
# (as long as we're drawing the same number of points)
236241
turtle StarFlower 42 12 5 30 morph @(
237242
turtle StarFlower 42 12 5 30
238-
turtle rotate (Get-Random -Max 360) StarFlower 42 14.4 6 25
243+
turtle rotate (
244+
Get-Random -Max 360 -Min -360
245+
) StarFlower 42 14.4 6 25
239246
turtle StarFlower 42 12 5 30
240247
)
241248
.EXAMPLE
242249
# We can construct a 'scissor' by drawing two lines at an angle
243250
turtle Scissor 42 60
244251
.EXAMPLE
245252
# Drawing a scissor does not change the heading
246-
# So we can create a zig-zag pattern by multiply scissors
253+
#
254+
# We can create a zig-zag pattern by multiplying scissors
247255
turtle @('Scissor',42,60 * 4)
248256
.EXAMPLE
249257
# Getting a bit more interesting, we can create a polygon out of scissors
258+
#
250259
# We will continually rotate until we have turned a multiple of 360 degrees.
251260
Turtle ScissorPoly 23 90 120
252261
.EXAMPLE
253262
Turtle ScissorPoly 23 60 72
254263
.EXAMPLE
255264
# This can get very chaotic, if it takes a while to reach a multiple of 360
256-
# Build N scissor polygons
265+
#
266+
# Let's build a dozen scissor polygons.
257267
foreach ($n in 60..72) {
258268
Turtle ScissorPoly 16 $n $n
259269
}
260-
.EXAMPLE
261-
Turtle ScissorPoly 16 69 69
262270
.EXAMPLE
263271
# We can draw an outward spiral by growing a bit each step
264272
turtle StepSpiral
@@ -376,7 +384,20 @@ function Get-Turtle {
376384
turtle SierpinskiTriangle 42 4
377385
.EXAMPLE
378386
# Let's draw two reflected Sierpinski Triangles
379-
turtle rotate 60 SierpinskiTriangle 42 4 SierpinskiTriangle -42 4
387+
turtle @(
388+
'rotate', 60
389+
'SierpinskiTriangle', 42, 4
390+
'SierpinskiTriangle', -42, 4
391+
)
392+
.EXAMPLE
393+
# Now let's draw a dozen reflected Sierpinski Triangles
394+
turtle @(
395+
'rotate', 60,
396+
'SierpinskiTriangle', 42, 4,
397+
'SierpinskiTriangle', -42, 4,
398+
'rotate', 30 *
399+
12
400+
)
380401
.EXAMPLE
381402
# We can draw a 'Sierpinski Snowflake' with multiple Sierpinski Triangles.
382403
turtle @('rotate', 30, 'SierpinskiTriangle',42,4 * 12)

0 commit comments

Comments
 (0)