Skip to content

Commit 5bc8b66

Browse files
feat: Turtle.get/set_Start ( Fixes PoshWeb#245 )
1 parent c174c1d commit 5bc8b66

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Types/Turtle/get_Start.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<#
2+
.SYNOPSIS
3+
Gets the Start Vector a Turtle
4+
.DESCRIPTION
5+
Gets the starting vector for a Turtle.
6+
7+
Setting this value avoids an automatic calculation of a starting position.
8+
.EXAMPLE
9+
turtle width 300 height 300 start 50 square 200 start
10+
#>
11+
return $this.'.Start'

Types/Turtle/set_Start.ps1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<#
2+
.SYNOPSIS
3+
Sets the Start Vector for a Turtle
4+
.DESCRIPTION
5+
Sets the starting vector for a Turtle.
6+
7+
This avoids an automatic calculation of a starting position
8+
.EXAMPLE
9+
turtle width 300 height 300 start 50 square 200
10+
#>
11+
param(
12+
[PSObject]
13+
$Value
14+
)
15+
16+
17+
$aNewStart =
18+
if ($value -is [object[]] -and $value -as [float[]]) {
19+
[Numerics.Vector2]::new($value -as [float[]])
20+
} elseif ($value.GetType -and $value.GetType().IsPrimitive) {
21+
[Numerics.Vector2]::new($value,$value)
22+
} elseif ($value.X -and $value.Y) {
23+
[Numerics.Vector2]::new($value.X,$value.Y)
24+
}
25+
26+
if ($aNewStart) {
27+
$this | Add-Member NoteProperty '.Start' $aNewStart -Force
28+
}
29+
30+
31+

0 commit comments

Comments
 (0)