Skip to content

Commit 15aa433

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Turtle.get/set_ID ( Fixes #84 )
Using ID in Pattern and Canvas
1 parent 70fc93c commit 15aa433

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Turtle.types.ps1xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,12 +1281,12 @@ $this | Add-Member NoteProperty -Name '.BackgroundColor' -Value $value -Force
12811281
$viewBox = $this.ViewBox
12821282
$null, $null, $viewX, $viewY = $viewBox
12831283
"<style>canvas {max-width: 100%; height: 100%}</style>"
1284-
"<canvas id='turtle-canvas' width='$($viewX + 1)' height='$($viewY + 1)'></canvas>"
1284+
"<canvas id='$($this.ID)-canvas' width='$($viewX + 1)' height='$($viewY + 1)'></canvas>"
12851285

12861286
"<script>"
12871287
@"
12881288
window.onload = async function() {
1289-
var canvas = document.getElementById('turtle-canvas');
1289+
var canvas = document.getElementById('$($this.ID)-canvas');
12901290
var ctx = canvas.getContext('2d');
12911291
ctx.strokeStyle = '$($this.Stroke)'
12921292
ctx.lineWidth = '$(
@@ -1628,7 +1628,7 @@ $viewBox = $this.ViewBox
16281628
$null, $null, $viewX, $viewY = $viewBox
16291629
"<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%'>"
16301630
"<defs>"
1631-
"<pattern id='turtle-pattern' patternUnits='userSpaceOnUse' width='$viewX' height='$viewY' transform-origin='50% 50%'$(
1631+
"<pattern id='$($this.ID)-pattern' patternUnits='userSpaceOnUse' width='$viewX' height='$viewY' transform-origin='50% 50%'$(
16321632
if ($this.PatternTransform) {
16331633
" patternTransform='" + (
16341634
@(foreach ($key in $this.PatternTransform.Keys) {
@@ -1646,7 +1646,7 @@ $(
16461646
"<rect width='10000%' height='10000%' x='-5000%' y='-5000%' fill='$($this.BackgroundColor)' transform-origin='50% 50%' />"
16471647
}
16481648
)
1649-
"<rect width='10000%' height='10000%' x='-5000%' y='-5000%' fill='url(#turtle-pattern)' transform-origin='50% 50%' />"
1649+
"<rect width='10000%' height='10000%' x='-5000%' y='-5000%' fill='url(#$($this.ID)-pattern)' transform-origin='50% 50%' />"
16501650
"</svg>")
16511651

16521652
$segments -join '' -as [xml]

0 commit comments

Comments
 (0)