Skip to content

Commit 2dd9d10

Browse files
feat: Turtle.Step() ( Fixes #161 )
Using `.Step()` in `Forward()` and `GoTo()`
2 parents 659c0ed + 30fd7d8 commit 2dd9d10

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Turtle.types.ps1xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,38 @@ foreach ($n in 1..$Points) {
18671867

18681868
</Script>
18691869
</ScriptMethod>
1870+
<ScriptMethod>
1871+
<Name>Step</Name>
1872+
<Script>
1873+
&lt;#
1874+
.SYNOPSIS
1875+
Takes a Step
1876+
.DESCRIPTION
1877+
Makes a relative movement.
1878+
.EXAMPLE
1879+
turtle step 5 5 step 0 -5 step -5 0 save ./stepTriangle.svg
1880+
#&gt;
1881+
param(
1882+
# The DeltaX
1883+
[double]$DeltaX = 0,
1884+
# The DeltaY
1885+
[double]$DeltaY = 0
1886+
)
1887+
1888+
# If both coordinates are empty, there is no step
1889+
if ($DeltaX -or $DeltaY) {
1890+
$this.Position = $DeltaX, $DeltaY
1891+
if ($This.IsPenDown) {
1892+
$this.Steps += " l $DeltaX $DeltaY"
1893+
} else {
1894+
$this.Steps += " m $DeltaX $DeltaY"
1895+
}
1896+
}
1897+
1898+
return $this
1899+
1900+
</Script>
1901+
</ScriptMethod>
18701902
<ScriptMethod>
18711903
<Name>StepSpiral</Name>
18721904
<Script>

0 commit comments

Comments
 (0)