Skip to content

Commit b373046

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Turtle.get/set_Width/Height ( Fixes #125 )
1 parent 12a1c25 commit b373046

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

Turtle.types.ps1xml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,50 @@ if ($VerbosePreference -ne 'SilentlyContinue') {
18531853
}
18541854
</SetScriptBlock>
18551855
</ScriptProperty>
1856+
<ScriptProperty>
1857+
<Name>Height</Name>
1858+
<GetScriptBlock>
1859+
&lt;#
1860+
.SYNOPSIS
1861+
Gets the Turtle height
1862+
.DESCRIPTION
1863+
Gets the Turtle's ViewBox height.
1864+
.NOTES
1865+
If this has not been set, it will be automatically computed from the distance between the minimum and maximum.
1866+
.EXAMPLE
1867+
turtle rotate 90 forward 100 width
1868+
#&gt;
1869+
param()
1870+
if ($this.'.ViewBox') {
1871+
return @($this.'.ViewBox')[-1]
1872+
}
1873+
1874+
$viewY = $this.Maximum.Y + ($this.Minimum.Y * -1)
1875+
return $viewY
1876+
1877+
1878+
1879+
1880+
</GetScriptBlock>
1881+
<SetScriptBlock>
1882+
&lt;#
1883+
.SYNOPSIS
1884+
Sets the turtle height
1885+
.DESCRIPTION
1886+
Sets the Turtle viewbox height.
1887+
.NOTES
1888+
Once set, it will no longer be automatically computed.
1889+
#&gt;
1890+
param(
1891+
[double]
1892+
$height
1893+
)
1894+
1895+
$viewBox = $this.ViewBox
1896+
$this.ViewBox = $viewBox[0],$viewBox[1],$viewbox[-2], $height
1897+
1898+
</SetScriptBlock>
1899+
</ScriptProperty>
18561900
<ScriptProperty>
18571901
<Name>ID</Name>
18581902
<GetScriptBlock>
@@ -2609,6 +2653,49 @@ if ($chromeOutput -match '&lt;img\ssrc="data:image/\w+;base64,(?&lt;b64&gt;[^"]+
26092653

26102654
</GetScriptBlock>
26112655
</ScriptProperty>
2656+
<ScriptProperty>
2657+
<Name>Width</Name>
2658+
<GetScriptBlock>
2659+
&lt;#
2660+
.SYNOPSIS
2661+
Gets the Turtle width
2662+
.DESCRIPTION
2663+
Gets the Turtle's ViewBox width.
2664+
.NOTES
2665+
If this has not been set, it will be automatically computed from the distance between the minimum and maximum.
2666+
.EXAMPLE
2667+
turtle forward 100 width
2668+
#&gt;
2669+
if ($this.'.ViewBox') {
2670+
return @($this.'.ViewBox')[-2]
2671+
}
2672+
2673+
$viewX = $this.Maximum.X + ($this.Minimum.X * -1)
2674+
return $viewX
2675+
2676+
2677+
2678+
</GetScriptBlock>
2679+
<SetScriptBlock>
2680+
&lt;#
2681+
.SYNOPSIS
2682+
Sets the turtle width
2683+
.DESCRIPTION
2684+
Sets the Turtle viewbox width.
2685+
.NOTES
2686+
Once set, it will no longer be automatically computed.
2687+
#&gt;
2688+
param(
2689+
# The new viewbox width.
2690+
[double]
2691+
$Width
2692+
)
2693+
2694+
$viewBox = $this.ViewBox
2695+
$this.ViewBox = $viewBox[0],$viewBox[1],$width, $viewBox[-1]
2696+
2697+
</SetScriptBlock>
2698+
</ScriptProperty>
26122699
<ScriptProperty>
26132700
<Name>X</Name>
26142701
<GetScriptBlock>

0 commit comments

Comments
 (0)