Skip to content

Commit d87020d

Browse files
fix: Turtle.set_PatternAnimation ease of use ( Fixes #26 )
Allowing dictionary values
1 parent db9fff7 commit d87020d

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

Types/Turtle/set_PatternAnimation.ps1

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
param(
2-
[string]
2+
[PSObject]
33
$PatternAnimation
44
)
55

6-
$this | Add-Member -MemberType NoteProperty -Force -Name '.PatternAnimation' -Value $PatternAnimation
6+
$newAnimation = @(foreach ($animation in $PatternAnimation) {
7+
if ($animation -is [Collections.IDictionary]) {
8+
$animationCopy = [Ordered]@{} + $animation
9+
if (-not $animationCopy['attributeType']) {
10+
$animationCopy['attributeType'] = 'XML'
11+
}
12+
if (-not $animationCopy['attributeName']) {
13+
$animationCopy['attributeName'] = 'patternTransform'
14+
}
15+
if ($animationCopy.values -is [object[]]) {
16+
$animationCopy['values'] = $animationCopy['values'] -join ';'
17+
}
18+
19+
"<animateTransform $(
20+
@(foreach ($key in $animationCopy.Keys) {
21+
" $key='$([Web.HttpUtility]::HtmlAttributeEncode($animationCopy[$key]))'"
22+
}) -join ''
23+
)/>"
24+
}
25+
if ($animation -is [string]) {
26+
$animation
27+
}
28+
})
29+
30+
$this | Add-Member -MemberType NoteProperty -Force -Name '.PatternAnimation' -Value $newAnimation

0 commit comments

Comments
 (0)