Skip to content

Commit 1d60ca5

Browse files
Merge pull request #150 from PowerShellWeb/turtles-on-the-l
Turtle 0.1.6
2 parents 1c214f9 + 1c18a89 commit 1d60ca5

File tree

12 files changed

+578
-19
lines changed

12 files changed

+578
-19
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## Turtle 0.1.6:
2+
3+
* Vastly expanded Get-Turtle examples (#149)
4+
* Check out https://psturtle.com/Commands/Get-Turtle
5+
* New L-Systems:
6+
* BoardFractal (#142)
7+
* CrystalFractal (#143)
8+
* RingFractal (#144)
9+
* TileFractal (#145)
10+
* Pentaplexity (#146)
11+
* Fixing KochCurve parameter order (#147)
12+
* Added New-Turtle docs (#148)
13+
14+
115
## Turtle 0.1.5:
216

317
* New Shapes:

Commands/Get-Turtle.ps1

Lines changed: 189 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,204 @@
11
function Get-Turtle {
22
<#
33
.SYNOPSIS
4-
Gets Turtle in PowerShell
4+
Gets Turtles
55
.DESCRIPTION
6-
Gets, sets, and moves a turtle object in PowerShell.
6+
Gets turtles in a PowerShell.
77
.NOTES
8-
Each argument can be the name of a member of the turtle object.
8+
Turtle Graphics are pretty groovy.
9+
10+
They have been kicking it since 1966, and they are how computers first learned to draw.
911
10-
After a member name is encountered, subsequent arguments will be passed to the member as parameters.
12+
They kicked off the first computer-aided design boom and inspired generations of artists, engineers, mathematicians, and physicists.
13+
14+
They are also _incredibly_ easy to build.
15+
16+
A Turtle graphic is described with a series of moves.
17+
18+
Let's start with the core three moves:
19+
20+
Imagine you are a Turtle holding a pen.
21+
22+
* You can turn `rotate`
23+
* You can move `forward`
24+
* You can lift the pen
25+
26+
These are the three basic moves a turtle can make.
27+
28+
We can describe more complex moves by combining these steps.
29+
30+
Each argument can be the name of a move of the turtle object.
31+
32+
After a member name is encountered, subsequent arguments will be passed to the member as parameters.
33+
.EXAMPLE
34+
# We can write shapes as a series of steps
35+
turtle rotate 120 forward 42 rotate 120 forward 42 rotate 120 forward 42
1136
.EXAMPLE
12-
turtle square 50
37+
# We can also use a method.
38+
# Polygon will draw an an N-sided polygon.
39+
turtle polygon 10 5
1340
.EXAMPLE
41+
# A simple case of this is a square
42+
turtle square 42
43+
.EXAMPLE
44+
# If we rotate 45 degrees first, our square becomes a rhombus
45+
turtle rotate 45 square 42
46+
.EXAMPLE
47+
# We can draw a circle
1448
turtle circle 10
1549
.EXAMPLE
16-
turtle polygon 10 6
50+
# Or a pair of half-circles
51+
turtle circle 10 0.5 rotate 90 circle 10 0.5
1752
.EXAMPLE
53+
# We can multiply arrays in PowerShell
54+
# this can make composing complex shapes easier.
55+
# Let's take the previous example and repeat it 8 times.
56+
turtle @('circle',42,0.5,'rotate',90 * 8)
57+
.EXAMPLE
58+
# Let's make a triangle by multiplying steps
1859
turtle ('forward', 10, 'rotate', 120 * 3)
19-
60+
.EXAMPLE
61+
# Let's make a series of polygons, decreasing in size
62+
turtle polygon 10 6 polygon 10 5 polygon 10 4 polygon 10 3
63+
.EXAMPLE
64+
# We can also use a loop to produce a series of steps
65+
# Let's extend our previous example and make 9 polygons
66+
turtle @(
67+
foreach ($n in 12..3) {
68+
'polygon'
69+
42
70+
$n
71+
}
72+
)
73+
.EXAMPLE
74+
# We can use the same trick to make successively larger polygons
75+
turtle @(
76+
$sideCount = 3..8 | Get-Random
77+
foreach ($n in 1..5) {
78+
'polygon'
79+
$n * 10
80+
$sideCount
81+
}
82+
)
83+
.EXAMPLE
84+
# A flower is a series of repeated polygons and rotations
85+
turtle Flower
86+
.EXAMPLE
87+
# Flowers look pretty with any number of polygons
88+
turtle Flower 50 10 (3..12 | Get-Random) 36
89+
.EXAMPLE
90+
# Flowers get less dense as we increase the angle and decrease the repetitions
91+
turtle Flower 50 15 (3..12 | Get-Random) 24
92+
.EXAMPLE
93+
# Flowers get more dense as we decrease the angle and increase the repetitions.
94+
turtle Flower 50 5 (3..12 | Get-Random) 72
95+
.EXAMPLE
96+
# We can draw a pair of arcs and turn back after each one
97+
turtle ArcRight 42 45 rotate (180 - 45) ArcRight 42 45 rotate (180 - 45)
98+
.EXAMPLE
99+
# We call this a 'petal'
100+
turtle Petal 42 60
101+
.EXAMPLE
102+
# We can construct a flower out of petals
103+
turtle FlowerPetal
104+
.EXAMPLE
105+
# Adjusting the angle of the petal makes our petal wider or thinner
106+
turtle FlowerPetal 42 15 (20..60 | Get-Random) 24
107+
.EXAMPLE
108+
# Flower Petals get more dense as we decrease the angle and increase repetitions
109+
turtle FlowerPetal 42 10 (10..50 | Get-Random) 36
110+
.EXAMPLE
111+
# Flower Petals get less dense as we increase the angle and decrease repetitions
112+
turtle FlowerPetal 50 20 (20..72 | Get-Random) 18
113+
.EXAMPLE
114+
# We can construct a 'scissor' by drawing two lines at an angle
115+
turtle Scissor 42 60
116+
.EXAMPLE
117+
# Drawing a scissor does not change the heading
118+
# So we can create a zig-zag pattern by multiply scissors
119+
turtle @('Scissor',42,60 * 4)
120+
.EXAMPLE
121+
# Getting a bit more interesting, we can create a polygon out of scissors
122+
# We will continually rotate until we have turned a multiple of 360 degrees.
123+
Turtle ScissorPoly 23 90 120
124+
.EXAMPLE
125+
Turtle ScissorPoly 23 60 72
126+
.EXAMPLE
127+
# This can get very chaotic, if it takes a while to reach a multiple of 360
128+
# Build N scissor polygons
129+
foreach ($n in 60..72) {
130+
Turtle ScissorPoly 16 $n $n
131+
}
132+
.EXAMPLE
133+
Turtle ScissorPoly 16 69 69
134+
.EXAMPLE
135+
# We can draw an outward spiral by growing a bit each step
136+
turtle StepSpiral
137+
.EXAMPLE
138+
turtle StepSpiral 42 120 4 18
139+
.EXAMPLE
140+
turtle @('StepSpiral',3, 120, 'rotate',60 * 6)
141+
.EXAMPLE
142+
turtle @('StepSpiral',3, 90, 'rotate',90 * 4)
143+
.EXAMPLE
144+
turtle spirolateral
145+
.EXAMPLE
146+
turtle spirolateral 50 60 10
147+
.EXAMPLE
148+
turtle spirolateral 50 120 6 @(1,3)
149+
.EXAMPLE
150+
turtle spirolateral 23 144 8
151+
.EXAMPLE
152+
turtle spirolateral 23 72 8
153+
.EXAMPLE
154+
turtle @('ArcLeft', 42, 12, 'ArcRight', 72, 60 * 6 )
155+
.EXAMPLE
156+
# Turtle can draw a number of fractals
157+
turtle BoxFractal 42 4
158+
.EXAMPLE
159+
# We can make a Board Fractal
160+
turtle BoardFractal 42 4
161+
.EXAMPLE
162+
# We can make a Crystal Fractal
163+
turtle CrystalFractal 42 4
164+
.EXAMPLE
165+
# We can make ring fractals
166+
turtle RingFractal 42 4
167+
.EXAMPLE
168+
# We can make a Pentaplexity
169+
turtle Pentaplexity 42 3
170+
.EXAMPLE
171+
# We can draw the Koch Island
172+
turtle KochIsland 42 4
173+
.EXAMPLE
174+
# Or we can draw the Koch Curve
175+
turtle KochCurve 42
176+
.EXAMPLE
177+
# We can make a Koch Snowflake
178+
turtle KochSnowflake 42
179+
.EXAMPLE
180+
# We can use a Hilbert Curve to fill a space
181+
Turtle HilbertCurve 42 4
182+
.EXAMPLE
183+
# We can use a Moore Curve to fill a space with a bit more density.
184+
turtle MooreCurve 42 4
185+
.EXAMPLE
186+
# We can show a binary tree
187+
turtle BinaryTree 42 4
188+
.EXAMPLE
189+
# We can also mimic plant growth
190+
turtle FractalPlant 42 4
191+
.EXAMPLE
192+
# The SierpinskiArrowHead Curve is pretty
193+
turtle SierpinskiArrowheadCurve 42 4
194+
.EXAMPLE
195+
# The SierpinskiTriangle is a Fractal classic
196+
turtle SierpinskiTriangle 42 4
197+
.EXAMPLE
198+
# We can draw a 'Sierpinski Snowflake' by rotating and drawing multiple Sierpinski Triangles
199+
turtle @('rotate', 30, 'SierpinskiTriangle',42,4 * 12)
200+
.EXAMPLE
201+
turtle @('rotate', 45, 'SierpinskiTriangle',42,4 * 24)
20202
#>
21203
[CmdletBinding(PositionalBinding=$false)]
22204
[Alias('turtle')]

Commands/New-Turtle.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@ function New-Turtle
22
{
33
<#
44
.SYNOPSIS
5-
Creates a new turtle object.
5+
Creates a new turtle.
66
.DESCRIPTION
7-
This function initializes a new turtle object with default properties.
7+
Creates a brand new turtle.
8+
.NOTES
9+
You can also create an empty turtle simply by calling `Get-Turtle` with no parameters.
810
.EXAMPLE
911
$turtle = New-Turtle
1012
$turtle.Square(100).Pattern.Save("$pwd/SquarePattern.svg")
13+
.EXAMPLE
14+
$newTurtle = New-Turtle
15+
$newTurtle.Polygon(42, 6)
16+
.EXAMPLE
17+
$NewTurtle = New-Turtle
1118
#>
1219
param()
1320
[PSCustomObject]@{PSTypeName='Turtle'}

Turtle.psd1

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@{
22
# Version number of this module.
3-
ModuleVersion = '0.1.5'
3+
ModuleVersion = '0.1.6'
44
# Description of the module
55
Description = "Turtles in a PowerShell"
66
# Script module or binary module file associated with this manifest.
@@ -37,14 +37,18 @@
3737
# A URL to the license for this module.
3838
LicenseURI = 'https://github.com/PowerShellWeb/Turtle/blob/main/LICENSE'
3939
ReleaseNotes = @'
40-
## Turtle 0.1.5:
41-
42-
* New Shapes:
43-
* Scissor draws a pair of lines at an angle (#128)
44-
* ScissorPoly draws a polygon out of scissors (#129)
45-
* Fixes:
46-
* OffsetPath is now quoted (#130)
47-
* ArcLeft/Right distance fix (#131)
40+
## Turtle 0.1.6:
41+
42+
* Vastly expanded Get-Turtle examples (#149)
43+
* Check out https://psturtle.com/Commands/Get-Turtle
44+
* New L-Systems:
45+
* BoardFractal (#142)
46+
* CrystalFractal (#143)
47+
* RingFractal (#144)
48+
* TileFractal (#145)
49+
* Pentaplexity (#146)
50+
* Fixing KochCurve parameter order (#147)
51+
* Added New-Turtle docs (#148)
4852
4953
---
5054

0 commit comments

Comments
 (0)