11function Get-Turtle {
22 <#
33 . SYNOPSIS
4- Gets Turtles
4+ Turtle Graphics in PowerShell
55 . DESCRIPTION
6- Gets turtles in a PowerShell .
6+ Turtle Graphics in PowerShell. Draw any image with turtles in a powershell .
77 . NOTES
88 Turtle Graphics are pretty groovy.
99
1010 They have been kicking it since 1966, and they are how computers first learned to draw.
1111
12- They kicked off the first computer-aided design boom and inspired generations of artists, engineers, mathematicians, and physicists .
12+ They kicked off the first computer-aided design boom and inspired generations.
1313
1414 They are also _incredibly_ easy to build.
1515
@@ -27,26 +27,26 @@ function Get-Turtle {
2727
2828 We can describe more complex moves by combining these steps.
2929
30- Each argument can be the name of a move of the turtle object .
30+ As a PowerShell turtle, we can take any pipeline of objects and turn them into turtles .
3131
32- After a member name is encountered, subsequent arguments will be passed to the member as parameters.
32+ Each argument can be the name of a method or property of the turtle object.
3333
34- Any parameter that begins with whitespace will be split into multiple words .
34+ After a member name is encountered, subsequent arguments will be passed to the member as parameters .
3535 . EXAMPLE
3636 # We can write shapes as a series of steps.
3737 # Let's start with a simple diagonal line
38- turtle rotate 45 forward 42
38+ turtle rotate 45 forward 42
3939 . EXAMPLE
40- # Let's draw a triangle
41- turtle forward 42 rotate 120 forward 42 rotate 120 forward 42
40+ # Let's draw an equilateral triangle
41+ turtle forward 42 rotate 120 forward 42 rotate 120 forward 42
4242 . EXAMPLE
4343 # Typing that might get tedious.
4444 # Instead, let's use a method.
4545 # Polygon will draw an an N-sided polygon.
4646 turtle polygon 10 5
4747 . EXAMPLE
4848 # There's also a method for squares
49- turtle square 42
49+ turtle square 42
5050 . EXAMPLE
5151 # If we rotate 45 degrees first, our square becomes a rhombus
5252 turtle rotate 45 square 42
@@ -539,17 +539,19 @@ function Get-Turtle {
539539 . EXAMPLE
540540 # We can draw negative circle arcs
541541 Turtle CircleArc 42 -90
542-
542+ . EXAMPLE
543543 # Negative quadrants
544544 Turtle @(
545545 'CircleArc',42, -90,
546546 'Rotate', 90 * 4
547547 )
548+ . EXAMPLE
548549 # Negative sextants
549550 Turtle @(
550551 'CircleArc',42, -60,
551552 'Rotate', 60 * 6
552553 )
554+ . EXAMPLE
553555 # Negative octants
554556 Turtle @(
555557 'CircleArc',42, -45,
@@ -617,8 +619,7 @@ function Get-Turtle {
617619 ) * 12
618620 )
619621 . EXAMPLE
620- # We can morph these exotic shapes to create hypnotic animations
621-
622+ # We can morph and spin these exotic shapes to create hypnotic animations
622623 $exoticShape = turtle (
623624 @(
624625 'circlearc', 21, -60,
@@ -629,7 +630,7 @@ function Get-Turtle {
629630 ) * 12
630631 )
631632
632- $exoticShape |
633+ $exoticShape |
633634 turtle morph @(
634635 $exoticShape
635636 turtle (
@@ -642,7 +643,11 @@ function Get-Turtle {
642643 ) * 12
643644 )
644645 $exoticShape
645- )
646+ ) pathAnimation @{
647+ type = 'rotate'
648+ values = 0, 360
649+ repeatCount = 'indefinite'
650+ }
646651 . EXAMPLE
647652 #### Turtles all the way down
648653 # Turtles can contain turtles.
@@ -728,16 +733,16 @@ function Get-Turtle {
728733 ) @colors
729734 )
730735 . EXAMPLE
731- #### Spiderwebs
732- # Turtle can draw spiderwebs
736+ #### Webs
737+ # Turtle can draw webs
733738 Turtle Spiderweb
734739 . EXAMPLE
735740 # Turtle can draw spiderwebs with any number of spokes and rings
736741 Turtle Spiderweb 7 13
737742 . EXAMPLE
738743 Turtle Spiderweb 7 13
739744 . EXAMPLE
740- # We can draw random spiderwebs
745+ # We can draw random webs
741746 $spokes = Get-Random -Min 3 -Max 13
742747 $rings = Get-Random -Min 3 -Max (13 * 3)
743748 turtle web 42 $spokes $rings morph @(
@@ -746,21 +751,21 @@ function Get-Turtle {
746751 Get-Random -Max 360
747752 ) web 42 $spokes $rings
748753 turtle web 42 $spokes $rings
749- ) stroke 'yellow ' pathclass 'yellow-stroke'
754+ ) stroke 'goldenrod ' pathclass 'yellow-stroke'
750755 . EXAMPLE
751- # We can draw a spiderweb with color and class
752- Turtle Spiderweb 7 13 stroke yellow pathclass 'yellow-stroke'
756+ # We can draw a web with color and class
757+ Turtle Spiderweb 7 13 stroke goldenrod pathclass 'yellow-stroke'
753758 . EXAMPLE
754- # We can draw a spiderweb with color and class
755- $spokes = Get-Random -Min 3 -Max 13
759+ # We can draw a random web with color and class
760+ $spokes = Get-Random -Min 5 -Max 13
756761 $rings = Get-Random -Min 3 -Max (13 * 3)
757762 turtle web 42 $spokes $rings morph @(
758763 turtle web 42 $spokes $rings
759764 turtle rotate (
760- Get-Random -Max 360
765+ Get-Random -Min 90 - Max 360
761766 ) web 42 $spokes $rings
762767 turtle web 42 $spokes $rings
763- ) stroke yellow pathclass 'yellow-stroke'
768+ ) stroke goldenrod pathclass 'yellow-stroke'
764769 . EXAMPLE
765770 #### L-Systems
766771 # Turtle can draw a number of fractals
@@ -819,9 +824,9 @@ function Get-Turtle {
819824 . EXAMPLE
820825 # We can morph with no parameters to try to draw step by step
821826 #
822- # This will result in large files.
827+ # This will result in large files, and may not work in all browsers
823828 #
824- # This may not work in all browsers for all graphics.
829+ # For best results, adjust the precision
825830 turtle SierpinskiTriangle 42 3 morph
826831 . EXAMPLE
827832 # Let's draw two reflected Sierpinski Triangles
0 commit comments