Skip to content

Commit 568570f

Browse files
author
James Brundage
committed
feat: Turtle.KochCurve ( Fixes #28 )
2 parents c9bc960 + 47ffb6b commit 568570f

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

Turtle.types.ps1xml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ return $this
113113

114114
</Script>
115115
</ScriptMethod>
116+
<ScriptMethod>
117+
<Name>Polygon</Name>
118+
<Script>
119+
param(
120+
$Size = 100,
121+
$SideCount = 6
122+
)
123+
124+
$null = foreach ($n in 1..$SideCount) {
125+
$this.Forward($Size)
126+
$this.Rotate(360 / $SideCount)
127+
}
128+
return $this
129+
</Script>
130+
</ScriptMethod>
116131
<ScriptMethod>
117132
<Name>Rotate</Name>
118133
<Script>
@@ -437,6 +452,53 @@ $viewY = $this.Maximum.Y + ($this.Minimum.Y * -1)
437452
) -join '' -as [xml]
438453
</GetScriptBlock>
439454
</ScriptProperty>
455+
<ScriptProperty>
456+
<Name>ViewBox</Name>
457+
<GetScriptBlock>
458+
if ($this.'.ViewBox') { return $this.'.ViewBox' }
459+
$viewX = $this.Maximum.X + ($this.Minimum.X * -1)
460+
$viewY = $this.Maximum.Y + ($this.Minimum.Y * -1)
461+
462+
return 0, 0, $viewX, $viewY
463+
464+
465+
466+
</GetScriptBlock>
467+
<SetScriptBlock>
468+
param(
469+
[double[]]
470+
$viewBox
471+
)
472+
473+
if ($viewBox.Length -gt 4) {
474+
$viewBox = $viewBox[0..3]
475+
}
476+
if ($viewBox.Length -lt 4) {
477+
if ($viewBox.Length -eq 3) {
478+
$viewBox = $viewBox[0], $viewBox[1], $viewBox[2],$viewBox[2]
479+
}
480+
if ($viewBox.Length -eq 2) {
481+
$viewBox = 0,0, $viewBox[0], $viewBox[1]
482+
}
483+
if ($viewBox.Length -eq 1) {
484+
$viewBox = 0,0, $viewBox[0], $viewBox[0]
485+
}
486+
}
487+
488+
if ($viewBox[0] -eq 0 -and
489+
$viewBox[1] -eq 0 -and
490+
$viewBox[2] -eq 0 -and
491+
$viewBox[3] -eq 0
492+
) {
493+
$viewX = $this.Maximum.X + ($this.Minimum.X * -1)
494+
$viewY = $this.Maximum.Y + ($this.Minimum.Y * -1)
495+
$viewBox = 0, 0, $viewX, $viewY
496+
}
497+
498+
$this | Add-Member -MemberType NoteProperty -Force -Name '.ViewBox' -Value $viewBox
499+
500+
</SetScriptBlock>
501+
</ScriptProperty>
440502
<NoteProperty>
441503
<Name>DefaultDisplay</Name>
442504
<Value>Heading

0 commit comments

Comments
 (0)