Skip to content

Commit 12a1c25

Browse files
feat: Turtle.get/set_Width/Height ( Fixes #125 )
1 parent 7f4980f commit 12a1c25

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

Types/Turtle/get_Height.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<#
2+
.SYNOPSIS
3+
Gets the Turtle height
4+
.DESCRIPTION
5+
Gets the Turtle's ViewBox height.
6+
.NOTES
7+
If this has not been set, it will be automatically computed from the distance between the minimum and maximum.
8+
.EXAMPLE
9+
turtle rotate 90 forward 100 width
10+
#>
11+
param()
12+
if ($this.'.ViewBox') {
13+
return @($this.'.ViewBox')[-1]
14+
}
15+
16+
$viewY = $this.Maximum.Y + ($this.Minimum.Y * -1)
17+
return $viewY
18+
19+
20+

Types/Turtle/get_Width.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<#
2+
.SYNOPSIS
3+
Gets the Turtle width
4+
.DESCRIPTION
5+
Gets the Turtle's ViewBox width.
6+
.NOTES
7+
If this has not been set, it will be automatically computed from the distance between the minimum and maximum.
8+
.EXAMPLE
9+
turtle forward 100 width
10+
#>
11+
if ($this.'.ViewBox') {
12+
return @($this.'.ViewBox')[-2]
13+
}
14+
15+
$viewX = $this.Maximum.X + ($this.Minimum.X * -1)
16+
return $viewX
17+
18+

Types/Turtle/set_Height.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<#
2+
.SYNOPSIS
3+
Sets the turtle height
4+
.DESCRIPTION
5+
Sets the Turtle viewbox height.
6+
.NOTES
7+
Once set, it will no longer be automatically computed.
8+
#>
9+
param(
10+
[double]
11+
$height
12+
)
13+
14+
$viewBox = $this.ViewBox
15+
$this.ViewBox = $viewBox[0],$viewBox[1],$viewbox[-2], $height

Types/Turtle/set_Width.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<#
2+
.SYNOPSIS
3+
Sets the turtle width
4+
.DESCRIPTION
5+
Sets the Turtle viewbox width.
6+
.NOTES
7+
Once set, it will no longer be automatically computed.
8+
#>
9+
param(
10+
# The new viewbox width.
11+
[double]
12+
$Width
13+
)
14+
15+
$viewBox = $this.ViewBox
16+
$this.ViewBox = $viewBox[0],$viewBox[1],$width, $viewBox[-1]

0 commit comments

Comments
 (0)