Skip to content

Commit a1cb81b

Browse files
feat: Turtle.Step() ( Fixes PoshWeb#161 )
1 parent 6402e9e commit a1cb81b

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Types/Turtle/Step.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<#
2+
.SYNOPSIS
3+
Takes a Step
4+
.DESCRIPTION
5+
Makes a relative movement.
6+
.EXAMPLE
7+
turtle step 5 5 step 0 -5 step -5 0 save ./stepTriangle.svg
8+
#>
9+
param(
10+
# The DeltaX
11+
[double]$DeltaX = 0,
12+
# The DeltaY
13+
[double]$DeltaY = 0
14+
)
15+
16+
# If both coordinates are empty, there is no step
17+
if ($DeltaX -or $DeltaY) {
18+
$this.Position = $DeltaX, $DeltaY
19+
if ($This.IsPenDown) {
20+
$this.Steps += " l $DeltaX $DeltaY"
21+
} else {
22+
$this.Steps += " m $DeltaX $DeltaY"
23+
}
24+
}
25+
26+
return $this

0 commit comments

Comments
 (0)