Skip to content

Commit 773920c

Browse files
docs: Turtle.Flower() partial polygon examples ( re #194 )
1 parent d4816c0 commit 773920c

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Types/Turtle/Flower.ps1

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,31 @@
55
Draws a flower pattern in turtle graphics.
66
77
This pattern consists of a series of polygons and rotations to create a flower-like design.
8+
.EXAMPLE
9+
turtle Flower 42
810
.EXAMPLE
9-
$turtle = New-Turtle
10-
$turtle.Flower(100, 10, 5, 36)
11-
$turtle.Pattern.Save("$pwd/FlowerPattern.svg")
11+
turtle Flower 42 20 6 18
1212
.EXAMPLE
13-
Move-Turtle Flower |
14-
Save-Turtle ./FlowerSymbol.svg
13+
turtle Flower 42 20 6 18
14+
.EXAMPLE
15+
# We can make Flowers with partial polygons
16+
turtle Flower 42 20 6.6 18
17+
.EXAMPLE
18+
# They are surprisingly beautiful
19+
turtle Flower 42 30 7.7 12
1520
#>
1621
param(
22+
# The size of the base shape
1723
[double]$Size = 100,
24+
# The rotation after each step
1825
[double]$Rotation = 10,
26+
# The number of sides in each shape
1927
[double]$SideCount = 4,
20-
[double]$StepCount = 36
28+
# The number of steps in the flower.
29+
[int]$StepCount = 36
2130
)
2231

23-
$null = foreach ($n in 1..$StepCount) {
32+
$null = foreach ($n in 1..([Math]::Abs($StepCount))) {
2433
$this.Polygon($Size, $SideCount)
2534
$this.Rotate($Rotation)
2635
}

0 commit comments

Comments
 (0)