Skip to content

Commit af48e65

Browse files
docs: Updating README
Now with command reference and more examples.
1 parent ce32521 commit af48e65

File tree

2 files changed

+85
-24
lines changed

2 files changed

+85
-24
lines changed

README.md

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3535
We can install Turtle from the PowerShell Gallery:
@@ -59,6 +59,15 @@ Import-Module ./ -Force -PassThru
5959

6060
Once 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+
109132
This 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+
111144
We 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
239267
Pop-Location

README.md.ps1

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ Turtle graphics starts with these two operations:
3737
* `Rotate()` rotates the turtle
3838
* `Forward()` moves forward
3939
40-
We can easily represent these steps in memory, and draw them within a webpage using SVG.
40+
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).
4141
42-
We can implement Turtle in any language.
42+
We can make Turtle in any language.
4343
44-
This module implements Turtle in PowerShell.
44+
This module makes Turtle in PowerShell.
4545
"@
4646

4747
#endregion Introduction
@@ -84,6 +84,15 @@ Import-Module ./ -Force -PassThru
8484
8585
Once we've imported Turtle, we can create any number of turtles, and control them with commands and methods.
8686
87+
The turtle is represented as an object, and any number of commands can make or move turtles.
88+
89+
* `New-Turtle` created a turtle
90+
* `Move-Turtle` performs a single turtle movement
91+
* `Set-Turtle` changes the turtle's properties
92+
* `Save-Turtle` saves the output of a turtle.
93+
94+
Last but not least: `Get-Turtle` lets you run multiple steps of turtle, and is aliased to `turtle`.
95+
8796
#### Drawing Simple Shapes
8897
8998
<div align='center'>
@@ -96,7 +105,7 @@ $(
96105
</div>
97106
98107
99-
Let's start simple, by drawing a square.
108+
Let's start simple, by drawing a square with a series of commands.
100109
101110
~~~PowerShell
102111
$(
@@ -143,7 +152,31 @@ foreach ($n in 1..4) {
143152
$turtle | Save-Turtle ./Square.svg
144153
~~~
145154
155+
Or we could use `Get-Turtle` directly.
156+
157+
~~~PowerShell
158+
turtle forward 10 rotate 90 forward 10 rotate 90 forward 10 rotate 90 forward 10 rotate 90 |
159+
Save-Turtle ./Square.svg
160+
~~~
161+
162+
Or we could use `Get-Turtle` with a bit of PowerShell multiplication magic:
163+
164+
~~~PowerShell
165+
turtle ('forward',10,'rotate',90 * 4) |
166+
Save-Turtle ./Square.svg
167+
~~~
168+
146169
This just demonstrates how we can construct shapes out of these two simple primitive steps.
170+
171+
There are a shell of a lot of ways you can draw any shape.
172+
173+
Turtle has many methods to help you draw, including a convenience method for squares.
174+
175+
So our shortest square can be written as:
176+
177+
~~~PowerShell
178+
turtle square 10 | Save-Turtle ./Square.svg
179+
~~~
147180
'@
148181

149182

0 commit comments

Comments
 (0)