Skip to content

Commit dda63d1

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Turtle.get/set_PathAnimation ( Fixes #117 )
1 parent a79c861 commit dda63d1

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

Turtle.types.ps1xml

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,53 @@ $this.PathAttribute = [Ordered]@{'opacity' = $Opacity}
17551755

17561756
</SetScriptBlock>
17571757
</ScriptProperty>
1758+
<ScriptProperty>
1759+
<Name>PathAnimation</Name>
1760+
<GetScriptBlock>
1761+
if ($this.'.PathAnimation') {
1762+
return $this.'.PathAnimation'
1763+
}
1764+
1765+
</GetScriptBlock>
1766+
<SetScriptBlock>
1767+
param(
1768+
[PSObject]
1769+
$PathAnimation
1770+
)
1771+
1772+
$newAnimation = @(foreach ($animation in $PathAnimation) {
1773+
if ($animation -is [Collections.IDictionary]) {
1774+
$animationCopy = [Ordered]@{} + $animation
1775+
if (-not $animationCopy['attributeType']) {
1776+
$animationCopy['attributeType'] = 'XML'
1777+
}
1778+
if (-not $animationCopy['attributeName']) {
1779+
$animationCopy['attributeName'] = 'transform'
1780+
}
1781+
if ($animationCopy.values -is [object[]]) {
1782+
$animationCopy['values'] = $animationCopy['values'] -join ';'
1783+
}
1784+
1785+
$elementName = 'animate'
1786+
if ($animationCopy['attributeName'] -eq 'transform') {
1787+
$elementName = 'animateTransform'
1788+
}
1789+
1790+
"&lt;$elementName $(
1791+
@(foreach ($key in $animationCopy.Keys) {
1792+
" $key='$([Web.HttpUtility]::HtmlAttributeEncode($animationCopy[$key]))'"
1793+
}) -join ''
1794+
)/&gt;"
1795+
}
1796+
if ($animation -is [string]) {
1797+
$animation
1798+
}
1799+
})
1800+
1801+
$this | Add-Member -MemberType NoteProperty -Force -Name '.PathAnimation' -Value $newAnimation
1802+
1803+
</SetScriptBlock>
1804+
</ScriptProperty>
17581805
<ScriptProperty>
17591806
<Name>PathAttribute</Name>
17601807
<GetScriptBlock>
@@ -1837,11 +1884,13 @@ $this | Add-Member -MemberType NoteProperty -Force -Name '.PathClass' -Value @(
18371884
if ($this.StrokeWidth) { $this.StrokeWidth } else { '0.1%' }
18381885
)' fill='$($this.Fill)' class='$(
18391886
$this.PathClass -join ' '
1840-
)' $(
1887+
)' transform-origin='50% 50%' $(
18411888
foreach ($pathAttributeName in $this.PathAttribute.Keys) {
18421889
" $pathAttributeName='$($this.PathAttribute[$pathAttributeName])'"
18431890
}
1844-
) /&gt;"
1891+
)&gt;"
1892+
if ($this.PathAnimation) {$this.PathAnimation}
1893+
"&lt;/path&gt;"
18451894
) -as [xml]
18461895
</GetScriptBlock>
18471896
</ScriptProperty>

0 commit comments

Comments
 (0)