Skip to content

Commit 368c561

Browse files
StartAutomatingStartAutomating
authored andcommitted
fix: Turtle.set_PatternAnimation ease of use ( Fixes #26 )
Allowing dictionary values
1 parent 49b46c9 commit 368c561

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

Turtle.types.ps1xml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,11 +1578,35 @@ $segments -join '' -as [xml]
15781578
</GetScriptBlock>
15791579
<SetScriptBlock>
15801580
param(
1581-
[string]
1581+
[PSObject]
15821582
$PatternAnimation
15831583
)
15841584

1585-
$this | Add-Member -MemberType NoteProperty -Force -Name '.PatternAnimation' -Value $PatternAnimation
1585+
$newAnimation = @(foreach ($animation in $PatternAnimation) {
1586+
if ($animation -is [Collections.IDictionary]) {
1587+
$animationCopy = [Ordered]@{} + $animation
1588+
if (-not $animationCopy['attributeType']) {
1589+
$animationCopy['attributeType'] = 'XML'
1590+
}
1591+
if (-not $animationCopy['attributeName']) {
1592+
$animationCopy['attributeName'] = 'patternTransform'
1593+
}
1594+
if ($animationCopy.values -is [object[]]) {
1595+
$animationCopy['values'] = $animationCopy['values'] -join ';'
1596+
}
1597+
1598+
"&lt;animateTransform $(
1599+
@(foreach ($key in $animationCopy.Keys) {
1600+
" $key='$([Web.HttpUtility]::HtmlAttributeEncode($animationCopy[$key]))'"
1601+
}) -join ''
1602+
)/&gt;"
1603+
}
1604+
if ($animation -is [string]) {
1605+
$animation
1606+
}
1607+
})
1608+
1609+
$this | Add-Member -MemberType NoteProperty -Force -Name '.PatternAnimation' -Value $newAnimation
15861610

15871611
</SetScriptBlock>
15881612
</ScriptProperty>

0 commit comments

Comments
 (0)