Skip to content

Commit 4cdd91e

Browse files
Merge pull request #158 from PowerShellWeb/turtle-metamorphosis
Turtle 0.1.7
2 parents f34f17c + 9234aae commit 4cdd91e

File tree

11 files changed

+542
-26
lines changed

11 files changed

+542
-26
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## Turtle 0.1.7:
2+
3+
* Morphing Turtles
4+
* `Turtle.Morph` morphs shapes (#154)
5+
* `Turtle.get/set_Duration` control animation durations (#153)
6+
* [Lots of new examples](https://psturtle.com/Commands/Get-Turtle)
7+
* New Fractals:
8+
* LevyCurve (#155)
9+
* Triplexity (#156)
10+
11+
---
12+
113
## Turtle 0.1.6:
214

315
* Vastly expanded Get-Turtle examples (#149)

Commands/Get-Turtle.ps1

Lines changed: 113 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,32 @@ function Get-Turtle {
8787
$sideCount
8888
}
8989
)
90+
.EXAMPLE
91+
# We can morph any N shapes with the same number of points.
92+
turtle square 42 morph @(
93+
turtle square 42
94+
turtle rotate 45 square 42
95+
turtle square 42
96+
)
97+
.EXAMPLE
98+
# This animates the path of the turtle.
99+
# If we want to morph a smaller shape into a bigger shape,
100+
# we can duplicate more lines
101+
turtle polygon 21 6 morph @(
102+
turtle @('forward', 21,'backward', 21 * 3)
103+
turtle polygon 21 6
104+
turtle @('forward', 21,'backward', 21 * 3)
105+
)
106+
.EXAMPLE
107+
# We can repeat steps by multiplying arrays.
108+
# Lets repeat a hexagon three times with a rotation
109+
turtle ('polygon', 23, 6, 'rotate', -120 * 3)
110+
.EXAMPLE
111+
# Let's change the angle a bit and see how they overlap
112+
turtle ('polygon', 23, 6, 'rotate', -60 * 6)
113+
.EXAMPLE
114+
# Let's do the same thing, but with a smaller angle
115+
turtle ('polygon', 23, 6, 'rotate', -40 * 9)
90116
.EXAMPLE
91117
# A flower is a series of repeated polygons and rotations
92118
turtle Flower
@@ -99,6 +125,14 @@ function Get-Turtle {
99125
.EXAMPLE
100126
# Flowers get more dense as we decrease the angle and increase the repetitions.
101127
turtle Flower 50 5 (3..12 | Get-Random) 72
128+
.EXAMPLE
129+
# Flowers look especially beautiful as they morph
130+
$sideCount = (3..12 | Get-Random)
131+
turtle Flower 50 15 $sideCount 36 morph @(
132+
turtle Flower 50 10 $sideCount 72
133+
turtle rotate (Get-Random -Max 360 -Min 180) Flower 50 5 $sideCount 72
134+
turtle Flower 50 10 $sideCount 72
135+
)
102136
.EXAMPLE
103137
# We can draw a pair of arcs and turn back after each one.
104138
# We call this a 'petal'.
@@ -114,7 +148,25 @@ function Get-Turtle {
114148
turtle FlowerPetal 42 10 (10..50 | Get-Random) 36
115149
.EXAMPLE
116150
# Flower Petals get less dense as we increase the angle and decrease repetitions
117-
turtle FlowerPetal 50 20 (20..72 | Get-Random) 18
151+
turtle FlowerPetal 50 20 (20..72 | Get-Random) 18
152+
.EXAMPLE
153+
# Flower Petals look amazing when morphed
154+
$Radius = 23..42 | Get-Random
155+
$flowerAngle = 30..60 | Get-Random
156+
$AngleFactor = 2..6 | Get-Random
157+
$flowerPetals = turtle rotate (
158+
(Get-Random -Max 180) * -1
159+
) flowerPetal $radius 10 $flowerAngle $stepCount
160+
$flowerPetals2 = turtle rotate (
161+
(Get-Random -Max 180)
162+
) flowerPetal $radius (
163+
10 * $AngleFactor
164+
) $flowerAngle $stepCount
165+
turtle flowerPetal $radius 10 $flowerAngle $stepCount morph (
166+
$flowerPetals,
167+
$flowerPetals2,
168+
$flowerPetals
169+
)
118170
.EXAMPLE
119171
# We can construct a 'scissor' by drawing two lines at an angle
120172
turtle Scissor 42 60
@@ -140,21 +192,69 @@ function Get-Turtle {
140192
# We can draw an outward spiral by growing a bit each step
141193
turtle StepSpiral
142194
.EXAMPLE
143-
turtle StepSpiral 42 120 4 18
195+
turtle StepSpiral 42 120 4 18
196+
.EXAMPLE
197+
# Because Step Spirals are a fixed number of steps,
198+
# they are easy to morph.
199+
turtle StepSpiral 42 120 4 18 morph @(
200+
turtle StepSpiral 42 90 4 24
201+
turtle StepSpiral 42 120 4 24
202+
turtle StepSpiral 42 90 4 24
203+
)
144204
.EXAMPLE
145205
turtle @('StepSpiral',3, 120, 'rotate',60 * 6)
146206
.EXAMPLE
147207
turtle @('StepSpiral',3, 90, 'rotate',90 * 4)
208+
.EXAMPLE
209+
# Step spirals look lovely when morphed
210+
#
211+
# (especially when reversing angles)
212+
turtle @('StepSpiral',3, 120, 'rotate',60 * 6) morph @(
213+
turtle @('StepSpiral',3, 120, 'rotate',60 * 6)
214+
turtle @('StepSpiral',6, -120, 'rotate',120 * 6)
215+
turtle @('StepSpiral',3, 120, 'rotate',60 * 6)
216+
)
217+
.EXAMPLE
218+
# When we reverse the spiral angle, the step spiral curve flips
219+
turtle @('StepSpiral',3, 90, 'rotate',90 * 4) morph @(
220+
turtle @('StepSpiral',3, 90, 'rotate',90 * 4)
221+
turtle @('StepSpiral',3, -90, 'rotate',90 * 4)
222+
turtle @('StepSpiral',3, 90, 'rotate',90 * 4)
223+
)
224+
.EXAMPLE
225+
# When we reverse the rotation, the step spiral curve slides
226+
turtle @('StepSpiral',3, 90, 'rotate',90 * 4) morph @(
227+
turtle @('StepSpiral',3, 90, 'rotate',90 * 4)
228+
turtle @('StepSpiral',3, 90, 'rotate',-90 * 4)
229+
turtle @('StepSpiral',3, 90, 'rotate',90 * 4)
230+
)
231+
.EXAMPLE
232+
# We we alternate, it looks amazing
233+
turtle @('StepSpiral',3, 90, 'rotate',90 * 4) morph @(
234+
turtle @('StepSpiral',3, 90, 'rotate',90 * 4)
235+
turtle @('StepSpiral',3, 90, 'rotate',-90 * 4)
236+
turtle @('StepSpiral',3, 90, 'rotate',90 * 4)
237+
turtle @('StepSpiral',3, -90, 'rotate',90 * 4)
238+
turtle @('StepSpiral',3, 90, 'rotate',90 * 4)
239+
)
240+
.EXAMPLE
241+
turtle @('StepSpiral',3, 120, 'rotate',60 * 6) morph @(
242+
turtle @('StepSpiral',3, 120, 'rotate',60 * 6)
243+
turtle @('StepSpiral',6, -120, 'rotate',120 * 6)
244+
turtle @('StepSpiral',3, 120, 'rotate',60 * 6)
245+
turtle @('StepSpiral',6, 120, 'rotate',-120 * 6)
246+
turtle @('StepSpiral',3, 120, 'rotate',60 * 6)
247+
)
148248
.EXAMPLE
149249
turtle spirolateral
150250
.EXAMPLE
151251
turtle spirolateral 50 60 10
152252
.EXAMPLE
153-
turtle spirolateral 50 120 6 @(1,3)
253+
turtle spirolateral 50 120 6 @(1,3)
154254
.EXAMPLE
155255
turtle spirolateral 23 144 8
156256
.EXAMPLE
157-
turtle spirolateral 23 72 8
257+
turtle spirolateral 23 72 8
158258
.EXAMPLE
159259
# Turtle can draw a number of fractals
160260
turtle BoxFractal 42 4
@@ -170,6 +270,9 @@ function Get-Turtle {
170270
.EXAMPLE
171271
# We can make a Pentaplexity
172272
turtle Pentaplexity 42 3
273+
.EXAMPLE
274+
# We can make a Triplexity
275+
turtle Triplexity 42 4
173276
.EXAMPLE
174277
# We can draw the Koch Island
175278
turtle KochIsland 42 4
@@ -179,6 +282,9 @@ function Get-Turtle {
179282
.EXAMPLE
180283
# We can make a Koch Snowflake
181284
turtle KochSnowflake 42
285+
.EXAMPLE
286+
# We can draw the Levy Curve
287+
turtle LevyCurve 42 6
182288
.EXAMPLE
183289
# We can use a Hilbert Curve to fill a space
184290
Turtle HilbertCurve 42 4
@@ -198,7 +304,7 @@ function Get-Turtle {
198304
# The SierpinskiTriangle is a Fractal classic
199305
turtle SierpinskiTriangle 42 4
200306
.EXAMPLE
201-
# We can draw a 'Sierpinski Snowflake' by rotating and drawing multiple Sierpinski Triangles
307+
# We can draw a 'Sierpinski Snowflake' with multiple Sierpinski Triangles.
202308
turtle @('rotate', 30, 'SierpinskiTriangle',42,4 * 12)
203309
.EXAMPLE
204310
turtle @('rotate', 45, 'SierpinskiTriangle',42,4 * 24)
@@ -267,7 +373,7 @@ function Get-Turtle {
267373
# otherwise, leave the argument alone.
268374
$arg
269375
}
270-
})
376+
})
271377

272378
# Now that we have a series of words, we can process them.
273379
# We want to keep track of the current member,
@@ -282,7 +388,7 @@ function Get-Turtle {
282388
$arg = $wordsAndArguments[$argIndex]
283389
# If the argument is not in the member names list, we can complain about it.
284390
if ($arg -notin $memberNames) {
285-
if (-not $currentMember -and $arg -is [string]) {
391+
if (-not $currentMember -and $arg -is [string] -and "$arg".Trim()) {
286392
Write-Warning "Unknown command '$arg'."
287393
}
288394
continue

Turtle.psd1

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@{
22
# Version number of this module.
3-
ModuleVersion = '0.1.6'
3+
ModuleVersion = '0.1.7'
44
# Description of the module
55
Description = "Turtles in a PowerShell"
66
# Script module or binary module file associated with this manifest.
@@ -37,18 +37,15 @@
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.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)
40+
## Turtle 0.1.7:
41+
42+
* Morphing Turtles
43+
* `Turtle.Morph` morphs shapes (#154)
44+
* `Turtle.get/set_Duration` control animation durations (#153)
45+
* [Lots of new examples](https://psturtle.com/Commands/Get-Turtle)
46+
* New Fractals:
47+
* LevyCurve (#155)
48+
* Triplexity (#156)
5249
5350
---
5451

0 commit comments

Comments
 (0)