From a1cb81bd2eca5848f650230f78dfbe6b7a39c619 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Tue, 26 Aug 2025 10:55:31 -0700 Subject: [PATCH 01/21] feat: `Turtle.Step()` ( Fixes #161 ) --- Types/Turtle/Step.ps1 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Types/Turtle/Step.ps1 diff --git a/Types/Turtle/Step.ps1 b/Types/Turtle/Step.ps1 new file mode 100644 index 0000000..3988b7f --- /dev/null +++ b/Types/Turtle/Step.ps1 @@ -0,0 +1,26 @@ +<# +.SYNOPSIS + Takes a Step +.DESCRIPTION + Makes a relative movement. +.EXAMPLE + turtle step 5 5 step 0 -5 step -5 0 save ./stepTriangle.svg +#> +param( +# The DeltaX +[double]$DeltaX = 0, +# The DeltaY +[double]$DeltaY = 0 +) + +# If both coordinates are empty, there is no step +if ($DeltaX -or $DeltaY) { + $this.Position = $DeltaX, $DeltaY + if ($This.IsPenDown) { + $this.Steps += " l $DeltaX $DeltaY" + } else { + $this.Steps += " m $DeltaX $DeltaY" + } +} + +return $this From 30fd7d858f7347f6662fcc03a16557698037cd6f Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Tue, 26 Aug 2025 17:56:08 +0000 Subject: [PATCH 02/21] feat: `Turtle.Step()` ( Fixes #161 ) --- Turtle.types.ps1xml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Turtle.types.ps1xml b/Turtle.types.ps1xml index c52d98f..616c1b4 100644 --- a/Turtle.types.ps1xml +++ b/Turtle.types.ps1xml @@ -1867,6 +1867,38 @@ foreach ($n in 1..$Points) { + + Step + + StepSpiral @@ -626,15 +629,10 @@ $X, $Y ) -$deltaX = $x - $this.X -$deltaY = $y - $this.Y -if ($this.IsPenDown) { - $this.Steps += " l $deltaX $deltaY" -} else { - $this.Steps += " m $deltaX $deltaY" -} -$this.Position = $deltaX, $deltaY -return $this +return $this.Step( + $x - $this.X, + $y - $this.Y +) From 280f822d747e9633c9fe17b19563f3bda62f4901 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Tue, 26 Aug 2025 11:02:17 -0700 Subject: [PATCH 05/21] feat: `Turtle.Step()` ( Fixes #161 ) Using `.Step()` in `Teleport()` --- Types/Turtle/Teleport.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Types/Turtle/Teleport.ps1 b/Types/Turtle/Teleport.ps1 index 07c2fe6..4149c4d 100644 --- a/Types/Turtle/Teleport.ps1 +++ b/Types/Turtle/Teleport.ps1 @@ -18,6 +18,8 @@ $Y $deltaX = $x - $this.X $deltaY = $y - $this.Y -$this.Steps += "m $deltaX $deltaY" -$this.Position = $deltaX, $deltaY +$penState = $this.IsPenDown +$this.IsPenDown = $false +$null = $this.Step($deltaX, $deltaY) +$this.IsPenDown = $penState return $this \ No newline at end of file From 480e8de9a1ce65ec6b723d0c5d8c14533c98a572 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Tue, 26 Aug 2025 18:02:35 +0000 Subject: [PATCH 06/21] feat: `Turtle.Step()` ( Fixes #161 ) Using `.Step()` in `Teleport()` --- Turtle.types.ps1xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Turtle.types.ps1xml b/Turtle.types.ps1xml index fd35f28..20041e3 100644 --- a/Turtle.types.ps1xml +++ b/Turtle.types.ps1xml @@ -1976,8 +1976,10 @@ $Y $deltaX = $x - $this.X $deltaY = $y - $this.Y -$this.Steps += "m $deltaX $deltaY" -$this.Position = $deltaX, $deltaY +$penState = $this.IsPenDown +$this.IsPenDown = $false +$null = $this.Step($deltaX, $deltaY) +$this.IsPenDown = $penState return $this From 8b8fe197dba3977422f99e9c711345230dc4f6fc Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Tue, 26 Aug 2025 11:03:49 -0700 Subject: [PATCH 07/21] feat: `Turtle.get/set_Steps` performance ( Fixes #159 ) --- Types/Turtle/get_Steps.ps1 | 10 +++++++--- Types/Turtle/set_Steps.ps1 | 9 ++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Types/Turtle/get_Steps.ps1 b/Types/Turtle/get_Steps.ps1 index ac07da6..ecac6e0 100644 --- a/Types/Turtle/get_Steps.ps1 +++ b/Types/Turtle/get_Steps.ps1 @@ -1,4 +1,8 @@ -if ($this.'.Steps') { - return $this.'.Steps' +if (-not $this.'.Steps') { + $this.psobject.properties.add( + [psnoteproperty]::new( + '.Steps', [Collections.Generic.List[string]]::new() + ), $false + ) } -return ,@() +return ,$this.'.Steps' diff --git a/Types/Turtle/set_Steps.ps1 b/Types/Turtle/set_Steps.ps1 index 2e3270e..4c7529e 100644 --- a/Types/Turtle/set_Steps.ps1 +++ b/Types/Turtle/set_Steps.ps1 @@ -11,4 +11,11 @@ param( $Steps ) -$this | Add-Member -MemberType NoteProperty -Force -Name '.Steps' -Value @($Steps) +if (-not $this.'.Steps') { + $this | Add-Member -MemberType NoteProperty -Force -Name '.Steps' -Value @( + [Collections.Generic.List[string]]::new($Steps) + ) +} else { + $this.'.Steps' = $steps +} + From 37815ee9cdb4cb740d3f4a968f9611c571036542 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Tue, 26 Aug 2025 18:04:10 +0000 Subject: [PATCH 08/21] feat: `Turtle.get/set_Steps` performance ( Fixes #159 ) --- Turtle.types.ps1xml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Turtle.types.ps1xml b/Turtle.types.ps1xml index 20041e3..09c92f3 100644 --- a/Turtle.types.ps1xml +++ b/Turtle.types.ps1xml @@ -3078,10 +3078,14 @@ $this.'.Stack' Steps - if ($this.'.Steps') { - return $this.'.Steps' + if (-not $this.'.Steps') { + $this.psobject.properties.add( + [psnoteproperty]::new( + '.Steps', [Collections.Generic.List[string]]::new() + ), $false + ) } -return ,@() +return ,$this.'.Steps' @@ -3098,7 +3102,14 @@ param( $Steps ) -$this | Add-Member -MemberType NoteProperty -Force -Name '.Steps' -Value @($Steps) +if (-not $this.'.Steps') { + $this | Add-Member -MemberType NoteProperty -Force -Name '.Steps' -Value @( + [Collections.Generic.List[string]]::new($Steps) + ) +} else { + $this.'.Steps' = $steps +} + From b772491648ed5458bc30169ba8dde76d7938d6f6 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Tue, 26 Aug 2025 18:04:46 +0000 Subject: [PATCH 09/21] feat: `Turtle.get/set_Steps` performance ( Fixes #159 ) --- Examples/BoxFractal.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/BoxFractal.svg b/Examples/BoxFractal.svg index e745d7c..a3771ef 100644 --- a/Examples/BoxFractal.svg +++ b/Examples/BoxFractal.svg @@ -1,6 +1,6 @@ - + From 3799f58a962ab4030d19c83c9e9affe097e0da62 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Tue, 26 Aug 2025 18:04:47 +0000 Subject: [PATCH 10/21] feat: `Turtle.get/set_Steps` performance ( Fixes #159 ) --- Examples/EndlessBoxFractal.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/EndlessBoxFractal.svg b/Examples/EndlessBoxFractal.svg index b31525d..7134fff 100644 --- a/Examples/EndlessBoxFractal.svg +++ b/Examples/EndlessBoxFractal.svg @@ -6,7 +6,7 @@ - + From 1765c879a231d102dd9188851c7e84f71e9568a5 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Tue, 26 Aug 2025 18:04:47 +0000 Subject: [PATCH 11/21] feat: `Turtle.get/set_Steps` performance ( Fixes #159 ) --- Examples/EndlessHilbert.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/EndlessHilbert.svg b/Examples/EndlessHilbert.svg index 996cd0e..6243f0d 100644 --- a/Examples/EndlessHilbert.svg +++ b/Examples/EndlessHilbert.svg @@ -6,7 +6,7 @@ - + From 56a2f0e8352f5ec5659348976ad6b431fbb6d458 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Tue, 26 Aug 2025 18:04:47 +0000 Subject: [PATCH 12/21] feat: `Turtle.get/set_Steps` performance ( Fixes #159 ) --- Examples/EndlessScissorPoly.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/EndlessScissorPoly.svg b/Examples/EndlessScissorPoly.svg index 74d3ba9..e2cfff0 100644 --- a/Examples/EndlessScissorPoly.svg +++ b/Examples/EndlessScissorPoly.svg @@ -6,7 +6,7 @@ - + From 1e671c2c29630983530daf42bd8569540a051171 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Tue, 26 Aug 2025 18:04:47 +0000 Subject: [PATCH 13/21] feat: `Turtle.get/set_Steps` performance ( Fixes #159 ) --- Examples/EndlessSierpinskiTrianglePattern.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/EndlessSierpinskiTrianglePattern.svg b/Examples/EndlessSierpinskiTrianglePattern.svg index 01fdacc..cca5d4d 100644 --- a/Examples/EndlessSierpinskiTrianglePattern.svg +++ b/Examples/EndlessSierpinskiTrianglePattern.svg @@ -6,7 +6,7 @@ - + From 534f0193934b9f3e39eed5cc6ee0a8af1ded37c0 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Tue, 26 Aug 2025 18:04:47 +0000 Subject: [PATCH 14/21] feat: `Turtle.get/set_Steps` performance ( Fixes #159 ) --- Examples/EndlessSnowflake.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/EndlessSnowflake.svg b/Examples/EndlessSnowflake.svg index 5e944d6..8d48d65 100644 --- a/Examples/EndlessSnowflake.svg +++ b/Examples/EndlessSnowflake.svg @@ -6,7 +6,7 @@ - + From 7ecc5b485bb2fdf20d3459ff188f66cc9e6f8551 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Tue, 26 Aug 2025 18:04:47 +0000 Subject: [PATCH 15/21] feat: `Turtle.get/set_Steps` performance ( Fixes #159 ) --- Examples/EndlessSpirolateral.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/EndlessSpirolateral.svg b/Examples/EndlessSpirolateral.svg index 2552f07..491d75c 100644 --- a/Examples/EndlessSpirolateral.svg +++ b/Examples/EndlessSpirolateral.svg @@ -6,7 +6,7 @@ - + From a0654c2b7a5eea2b211e7a9138a6a46e125259a9 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Tue, 26 Aug 2025 18:04:48 +0000 Subject: [PATCH 16/21] feat: `Turtle.get/set_Steps` performance ( Fixes #159 ) --- Examples/EndlessStepSpiral.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/EndlessStepSpiral.svg b/Examples/EndlessStepSpiral.svg index 4b6330d..2a30361 100644 --- a/Examples/EndlessStepSpiral.svg +++ b/Examples/EndlessStepSpiral.svg @@ -4,7 +4,7 @@ - + From dd6687207aae4163f4ae8af4df4a42d9a35d7ea7 Mon Sep 17 00:00:00 2001 From: James Brundage Date: Tue, 26 Aug 2025 18:04:48 +0000 Subject: [PATCH 17/21] feat: `Turtle.get/set_Steps` performance ( Fixes #159 ) --- Examples/SierpinskiTriangle.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/SierpinskiTriangle.svg b/Examples/SierpinskiTriangle.svg index 8d733a4..4000b31 100644 --- a/Examples/SierpinskiTriangle.svg +++ b/Examples/SierpinskiTriangle.svg @@ -1,6 +1,6 @@ - + From 1ea81ecd63864acd8cff9a35bf9c399802f14285 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Tue, 26 Aug 2025 11:08:44 -0700 Subject: [PATCH 18/21] feat: Reducing Turtle Verbosity ( Fixes #160 ) --- Types/Turtle/get_Heading.ps1 | 6 +++--- Types/Turtle/set_Heading.ps1 | 8 +------- Types/Turtle/set_IsPenDown.ps1 | 12 +++++------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Types/Turtle/get_Heading.ps1 b/Types/Turtle/get_Heading.ps1 index d2da812..ac7f31d 100644 --- a/Types/Turtle/get_Heading.ps1 +++ b/Types/Turtle/get_Heading.ps1 @@ -5,8 +5,8 @@ Gets the current heading of the turtle. #> param() -if ($null -ne $this.'.TurtleHeading') { - return $this.'.TurtleHeading' +if ($this -and -not $this.psobject.properties['.TurtleHeading']) { + $this.psobject.properties.add([PSNoteProperty]::new('.TurtleHeading', 0.0), $false) } -return 0 +return $this.'.TurtleHeading' diff --git a/Types/Turtle/set_Heading.ps1 b/Types/Turtle/set_Heading.ps1 index 48a6bd3..e5fa088 100644 --- a/Types/Turtle/set_Heading.ps1 +++ b/Types/Turtle/set_Heading.ps1 @@ -15,10 +15,4 @@ $Heading if ($this -and -not $this.psobject.properties['.TurtleHeading']) { $this.psobject.properties.add([PSNoteProperty]::new('.TurtleHeading', 0), $false) } -$this.'.TurtleHeading' = $Heading - -# $this.psobject.properties.add([PSNoteProperty]::new('.TurtleHeading', $Heading), $false) -# $this | Add-Member -MemberType NoteProperty -Force -Name '.TurtleHeading' -Value $Heading -if ($VerbosePreference -ne 'SilentlyContinue') { - Write-Verbose "Heading to $Heading" -} \ No newline at end of file +$this.'.TurtleHeading' = $Heading \ No newline at end of file diff --git a/Types/Turtle/set_IsPenDown.ps1 b/Types/Turtle/set_IsPenDown.ps1 index 6f6a3de..4ff306f 100644 --- a/Types/Turtle/set_IsPenDown.ps1 +++ b/Types/Turtle/set_IsPenDown.ps1 @@ -2,10 +2,8 @@ param( [bool] $IsDown ) - -$this | - Add-Member -MemberType NoteProperty -Force -Name '.IsPenDown' -Value $IsDown - -if ($VerbosePreference -ne 'SilentlyContinue') { - Write-Verbose "Turtle is now $($IsDown ? 'down' : 'up')" -} \ No newline at end of file +if ($null -eq $this.'.IsPenDown') { + $this | Add-Member -MemberType NoteProperty -Force -Name '.IsPenDown' -Value $IsDown +} else { + $this.'.IsPenDown' = $IsDown +} From d1f674db2d723f68d87ee02dde383ee1bc33e696 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Tue, 26 Aug 2025 18:09:12 +0000 Subject: [PATCH 19/21] feat: Reducing Turtle Verbosity ( Fixes #160 ) --- Turtle.types.ps1xml | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/Turtle.types.ps1xml b/Turtle.types.ps1xml index 09c92f3..5126e63 100644 --- a/Turtle.types.ps1xml +++ b/Turtle.types.ps1xml @@ -2428,10 +2428,10 @@ $this.PathAttribute = [Ordered]@{'fill-rule' = $fillRule.ToLower()} Gets the current heading of the turtle. #> param() -if ($null -ne $this.'.TurtleHeading') { - return $this.'.TurtleHeading' +if ($this -and -not $this.psobject.properties['.TurtleHeading']) { + $this.psobject.properties.add([PSNoteProperty]::new('.TurtleHeading', 0.0), $false) } -return 0 +return $this.'.TurtleHeading' @@ -2454,12 +2454,6 @@ if ($this -and -not $this.psobject.properties['.TurtleHeading']) { $this.psobject.properties.add([PSNoteProperty]::new('.TurtleHeading', 0), $false) } $this.'.TurtleHeading' = $Heading - -# $this.psobject.properties.add([PSNoteProperty]::new('.TurtleHeading', $Heading), $false) -# $this | Add-Member -MemberType NoteProperty -Force -Name '.TurtleHeading' -Value $Heading -if ($VerbosePreference -ne 'SilentlyContinue') { - Write-Verbose "Heading to $Heading" -} @@ -2532,13 +2526,12 @@ return $true [bool] $IsDown ) - -$this | - Add-Member -MemberType NoteProperty -Force -Name '.IsPenDown' -Value $IsDown - -if ($VerbosePreference -ne 'SilentlyContinue') { - Write-Verbose "Turtle is now $($IsDown ? 'down' : 'up')" +if ($null -eq $this.'.IsPenDown') { + $this | Add-Member -MemberType NoteProperty -Force -Name '.IsPenDown' -Value $IsDown +} else { + $this.'.IsPenDown' = $IsDown } + From 5c80058ebdf82a213465f866811b9aed0b672c99 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Tue, 26 Aug 2025 11:23:56 -0700 Subject: [PATCH 20/21] feat: Turtle Reflection Examples ( Fixes #162 ) --- Commands/Get-Turtle.ps1 | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Commands/Get-Turtle.ps1 b/Commands/Get-Turtle.ps1 index 6704f1f..16e97cd 100644 --- a/Commands/Get-Turtle.ps1 +++ b/Commands/Get-Turtle.ps1 @@ -64,6 +64,9 @@ function Get-Turtle { .EXAMPLE # Let's make a triangle by multiplying steps turtle ('forward', 10, 'rotate', 120 * 3) + .EXAMPLE + # We can also write this with a polygon + turtle polygon 10 3 .EXAMPLE # Let's make a series of polygons, decreasing in size turtle polygon 10 6 polygon 10 5 polygon 10 4 @@ -87,6 +90,12 @@ function Get-Turtle { $sideCount } ) + .EXAMPLE + # We can reflect a shape by drawing it with a negative number + turtle polygon 42 3 polygon -42 3 + .EXAMPLE + # We can change the angle of reflection by rotating first + turtle rotate 60 polygon 42 3 polygon -42 3 .EXAMPLE # We can morph any N shapes with the same number of points. turtle square 42 morph @( @@ -95,14 +104,23 @@ function Get-Turtle { turtle square 42 ) .EXAMPLE - # This animates the path of the turtle. + # Reflections always have the same number of points. + # + # Morphing a shape into its reflection will zoom out, flip, and zoom back in. + turtle polygon 42 6 morph @( + turtle polygon -42 6 + turtle polygon 42 6 + turtle polygon -42 6 + ) + .EXAMPLE # If we want to morph a smaller shape into a bigger shape, - # we can duplicate more lines + # + # we can duplicate lines turtle polygon 21 6 morph @( turtle @('forward', 21,'backward', 21 * 3) turtle polygon 21 6 turtle @('forward', 21,'backward', 21 * 3) - ) + ) .EXAMPLE # We can repeat steps by multiplying arrays. # Lets repeat a hexagon three times with a rotation @@ -304,6 +322,9 @@ function Get-Turtle { .EXAMPLE # The SierpinskiTriangle is a Fractal classic turtle SierpinskiTriangle 42 4 + .EXAMPLE + # Let's draw two reflected Sierpinski Triangles + turtle rotate 60 SierpinskiTriangle 42 4 SierpinskiTriangle -42 4 .EXAMPLE # We can draw a 'Sierpinski Snowflake' with multiple Sierpinski Triangles. turtle @('rotate', 30, 'SierpinskiTriangle',42,4 * 12) From 71f71a90a37d05ac09d6fc0ae65698b56e0de419 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Tue, 26 Aug 2025 11:27:06 -0700 Subject: [PATCH 21/21] release: Turtle 0.1.8 Updating Module Manifest and CHANGELOG --- CHANGELOG.md | 12 ++++++++++++ Turtle.psd1 | 20 ++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f24e377..4c42b4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## Turtle 0.1.8: + +* Turtle Performance + * Improving `.Steps` performance (#159) + * Reducing Turtle Verbosity (#160) +* New Moves: + * Step (#161) + * Forward,Teleport, and GoTo now use Step (#161) +* New Reflection Examples (#162) + +--- + ## Turtle 0.1.7: * Morphing Turtles diff --git a/Turtle.psd1 b/Turtle.psd1 index 4698faa..21acfbf 100644 --- a/Turtle.psd1 +++ b/Turtle.psd1 @@ -1,6 +1,6 @@ @{ # Version number of this module. - ModuleVersion = '0.1.7' + ModuleVersion = '0.1.8' # Description of the module Description = "Turtles in a PowerShell" # Script module or binary module file associated with this manifest. @@ -37,15 +37,15 @@ # A URL to the license for this module. LicenseURI = 'https://github.com/PowerShellWeb/Turtle/blob/main/LICENSE' ReleaseNotes = @' -## Turtle 0.1.7: - -* Morphing Turtles - * `Turtle.Morph` morphs shapes (#154) - * `Turtle.get/set_Duration` control animation durations (#153) - * [Lots of new examples](https://psturtle.com/Commands/Get-Turtle) -* New Fractals: - * LevyCurve (#155) - * Triplexity (#156) +## Turtle 0.1.8: + +* Turtle Performance + * Improving `.Steps` performance (#159) + * Reducing Turtle Verbosity (#160) +* New Moves: + * Step (#161) + * Forward,Teleport, and GoTo now use Step (#161) +* New Reflection Examples (#162) ---