@@ -25,11 +25,11 @@ Turtle graphics starts with these two operations:
2525* Rotate() rotates the turtle
2626* Forward() moves forward
2727
28- We can easily represent these steps in memory, and draw them within a webpage using SVG.
28+ We can easily keep a list of these steps in memory, and draw them with [ SVG] ( https://developer.mozilla.org/en-US/docs/Web/SVG ) .
2929
30- We can implement Turtle in any language.
30+ We can make Turtle in any language.
3131
32- This module implements Turtle in PowerShell.
32+ This module makes Turtle in PowerShell.
3333### Installing and Importing
3434
3535We can install Turtle from the PowerShell Gallery:
@@ -59,6 +59,15 @@ Import-Module ./ -Force -PassThru
5959
6060Once we've imported Turtle, we can create any number of turtles, and control them with commands and methods.
6161
62+ The turtle is represented as an object, and any number of commands can make or move turtles.
63+
64+ * New-Turtle created a turtle
65+ * Move-Turtle performs a single turtle movement
66+ * Set-Turtle changes the turtle's properties
67+ * Save-Turtle saves the output of a turtle.
68+
69+ Last but not least: Get-Turtle lets you run multiple steps of turtle, and is aliased to urtle.
70+
6271#### Drawing Simple Shapes
6372
6473<div align =' center ' >
@@ -67,7 +76,7 @@ Once we've imported Turtle, we can create any number of turtles, and control the
6776</div >
6877
6978
70- Let's start simple, by drawing a square.
79+ Let's start simple, by drawing a square with a series of commands .
7180
7281~~~ PowerShell
7382
@@ -106,8 +115,32 @@ foreach ($n in 1..4) {
106115$turtle | Save-Turtle ./Square.svg
107116~~~
108117
118+ Or we could use ` Get-Turtle ` directly.
119+
120+ ~~~ PowerShell
121+ turtle forward 10 rotate 90 forward 10 rotate 90 forward 10 rotate 90 forward 10 rotate 90 |
122+ Save-Turtle ./Square.svg
123+ ~~~
124+
125+ Or we could use ` Get-Turtle ` with a bit of PowerShell multiplication magic:
126+
127+ ~~~ PowerShell
128+ turtle ('forward',10,'rotate',90 * 4) |
129+ Save-Turtle ./Square.svg
130+ ~~~
131+
109132This just demonstrates how we can construct shapes out of these two simple primitive steps.
110133
134+ There are a shell of a lot of ways you can draw any shape.
135+
136+ Turtle has many methods to help you draw, including a convenience method for squares.
137+
138+ So our shortest square can be written as:
139+
140+ ~~~ PowerShell
141+ turtle square 10 | Save-Turtle ./Square.svg
142+ ~~~
143+
111144We can also just say, make a square directly:
112145
113146~~~ PowerShell
@@ -218,22 +251,17 @@ We can also animate the pattern, for endless variety:
218251$turtle = turtle KochSnowflake 10 4 |
219252 Set-Turtle -Property PatternTransform -Value @{scale=0.33} |
220253 set-turtle -property Fill -value '#4488ff' |
221- Set-Turtle -Property PatternAnimation -Value "
222-
223- <animateTransform attributeName='patternTransform' attributeType='XML' type='scale' values='0.66;0.33;0.66' dur='23s' repeatCount='indefinite' additive='sum' />
224-
225- <animateTransform attributeName='patternTransform' attributeType='XML' type='rotate' from='0' to='360' dur='41s' repeatCount='indefinite' additive='sum' />
226-
227- <animateTransform attributeName='patternTransform' attributeType='XML' type='skewX' values='30;-30;30' dur='83s' repeatCount='indefinite' additive='sum' />
228-
229- <animateTransform attributeName='patternTransform' attributeType='XML' type='skewY' values='30;-30;30' dur='103s' repeatCount='indefinite' additive='sum' />
230-
231- <animateTransform attributeName='patternTransform' attributeType='XML' type='translate' values='0 0;42 42;0 0' dur='117s' repeatCount='indefinite' additive='sum' />
232-
233- "
234-
235-
236-
254+ Set-Turtle -Property PatternAnimation -Value ([Ordered]@{
255+ type = 'scale' ; values = 0.66,0.33, 0.66 ; repeatCount = 'indefinite' ;dur = "23s"; additive = 'sum'
256+ }, [Ordered]@{
257+ type = 'rotate' ; values = 0, 360 ;repeatCount = 'indefinite'; dur = "41s"; additive = 'sum'
258+ }, [Ordered]@{
259+ type = 'skewX' ; values = -30,30,-30;repeatCount = 'indefinite';dur = "83s";additive = 'sum'
260+ }, [Ordered]@{
261+ type = 'skewY' ; values = 30,-30, 30;repeatCount = 'indefinite';additive = 'sum';dur = "103s"
262+ }, [Ordered]@{
263+ type = 'translate';values = "0 0","42 42", "0 0";repeatCount = 'indefinite';additive = 'sum';dur = "117s"
264+ })
237265
238266$turtle | save-turtle -Path ./EndlessSnowflake.svg -Property Pattern
239267Pop-Location
0 commit comments