Skip to content

Commit dbb7d55

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Turtle.get/set_ID ( Fixes #84 )
1 parent a15689d commit dbb7d55

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

Turtle.types.ps1xml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,20 @@ if ($VerbosePreference -ne 'SilentlyContinue') {
13571357
}
13581358
</SetScriptBlock>
13591359
</ScriptProperty>
1360+
<ScriptProperty>
1361+
<Name>ID</Name>
1362+
<GetScriptBlock>
1363+
if ($this.'.ID') { return $this.'.ID'}
1364+
return 'turtle'
1365+
1366+
</GetScriptBlock>
1367+
<SetScriptBlock>
1368+
param([string]$Value)
1369+
1370+
$this | Add-Member NoteProperty '.ID' $Value -Force
1371+
1372+
</SetScriptBlock>
1373+
</ScriptProperty>
13601374
<ScriptProperty>
13611375
<Name>IsPenDown</Name>
13621376
<GetScriptBlock>
@@ -1435,7 +1449,7 @@ if ($chromeOutput -match '&lt;img\ssrc="data:image/\w+;base64,(?&lt;b64&gt;[^"]+
14351449
$segments = @(
14361450
"&lt;svg xmlns='http://www.w3.org/2000/svg' width='0%' height='0%'&gt;"
14371451
"&lt;defs&gt;"
1438-
"&lt;mask id='turtle-mask'&gt;"
1452+
"&lt;mask id='$($this.Id)-mask'&gt;"
14391453
$this.Symbol.OuterXml -replace '\&lt;\?[^\&gt;]+\&gt;'
14401454
"&lt;/mask&gt;"
14411455
"&lt;/defs&gt;"
@@ -1552,7 +1566,7 @@ $this | Add-Member -MemberType NoteProperty -Force -Name '.PathClass' -Value @(
15521566
<Name>PathElement</Name>
15531567
<GetScriptBlock>
15541568
@(
1555-
"&lt;path id='turtle-path' d='$($this.PathData)' stroke='$(
1569+
"&lt;path id='$($this.id)-path' d='$($this.PathData)' stroke='$(
15561570
if ($this.Stroke) { $this.Stroke } else { 'currentColor' }
15571571
)' stroke-width='$(
15581572
if ($this.StrokeWidth) { $this.StrokeWidth } else { '0.1%' }
@@ -1663,7 +1677,7 @@ $b64 = [Convert]::ToBase64String($OutputEncoding.GetBytes($thisPattern.outerXml)
16631677
$segments = @(
16641678
"&lt;svg xmlns='http://www.w3.org/2000/svg' width='0%' height='0%'&gt;"
16651679
"&lt;defs&gt;"
1666-
"&lt;mask id='turtle-mask'&gt;"
1680+
"&lt;mask id='$($this.ID)-mask'&gt;"
16671681
$this.Pattern.OuterXml -replace '\&lt;\?[^\&gt;]+\&gt;'
16681682
"&lt;/mask&gt;"
16691683
"&lt;/defs&gt;"
@@ -1872,15 +1886,15 @@ param()
18721886

18731887
@(
18741888
"&lt;svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%' transform-origin='50% 50%'&gt;"
1875-
"&lt;symbol id='turtle-symbol' viewBox='$($this.ViewBox)' transform-origin='50% 50%'&gt;"
1889+
"&lt;symbol id='$($this.ID)-symbol' viewBox='$($this.ViewBox)' transform-origin='50% 50%'&gt;"
18761890
$this.PathElement.OuterXml
18771891
"&lt;/symbol&gt;"
18781892
$(
18791893
if ($this.BackgroundColor) {
18801894
"&lt;rect width='10000%' height='10000%' x='-5000%' y='-5000%' fill='$($this.BackgroundColor)' transform-origin='50% 50%' /&gt;"
18811895
}
18821896
)
1883-
"&lt;use href='#turtle-symbol' width='100%' height='100%' transform-origin='50% 50%' /&gt;"
1897+
"&lt;use href='#$($this.ID)-symbol' width='100%' height='100%' transform-origin='50% 50%' /&gt;"
18841898
"&lt;/svg&gt;"
18851899
) -join '' -as [xml]
18861900
</GetScriptBlock>

0 commit comments

Comments
 (0)