Skip to content

Commit 388b17d

Browse files
author
James Brundage
committed
feat: Turtle.get/set_ViewBox ( Fixes #30 )
1 parent 1b52bf8 commit 388b17d

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Types/Turtle/get_ViewBox.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if ($this.'.ViewBox') { return $this.'.ViewBox' }
2+
$viewX = $this.Maximum.X + ($this.Minimum.X * -1)
3+
$viewY = $this.Maximum.Y + ($this.Minimum.Y * -1)
4+
5+
return 0, 0, $viewX, $viewY
6+
7+

Types/Turtle/set_ViewBox.ps1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
param(
2+
[double[]]
3+
$viewBox
4+
)
5+
6+
if ($viewBox.Length -gt 4) {
7+
$viewBox = $viewBox[0..3]
8+
}
9+
if ($viewBox.Length -lt 4) {
10+
if ($viewBox.Length -eq 3) {
11+
$viewBox = $viewBox[0], $viewBox[1], $viewBox[2],$viewBox[2]
12+
}
13+
if ($viewBox.Length -eq 2) {
14+
$viewBox = 0,0, $viewBox[0], $viewBox[1]
15+
}
16+
if ($viewBox.Length -eq 1) {
17+
$viewBox = 0,0, $viewBox[0], $viewBox[0]
18+
}
19+
}
20+
21+
if ($viewBox[0] -eq 0 -and
22+
$viewBox[1] -eq 0 -and
23+
$viewBox[2] -eq 0 -and
24+
$viewBox[3] -eq 0
25+
) {
26+
$viewX = $this.Maximum.X + ($this.Minimum.X * -1)
27+
$viewY = $this.Maximum.Y + ($this.Minimum.Y * -1)
28+
$viewBox = 0, 0, $viewX, $viewY
29+
}
30+
31+
$this | Add-Member -MemberType NoteProperty -Force -Name '.ViewBox' -Value $viewBox

0 commit comments

Comments
 (0)