Skip to content

Commit 250eb66

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Turtle.Duration ( Fixes #153 )
1 parent 5aaa3bb commit 250eb66

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Turtle.types.ps1xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,6 +2136,43 @@ $b64 = [Convert]::ToBase64String($OutputEncoding.GetBytes($thisSymbol.outerXml))
21362136
"data:image/svg+xml;base64,$b64"
21372137
</GetScriptBlock>
21382138
</ScriptProperty>
2139+
<ScriptProperty>
2140+
<Name>Duration</Name>
2141+
<GetScriptBlock>
2142+
&lt;#
2143+
.SYNOPSIS
2144+
Gets the duration
2145+
.DESCRIPTION
2146+
Gets the default duration of animations and morphs.
2147+
#&gt;
2148+
if ($this.'.Duration') { return $this.'.Duration'}
2149+
return
2150+
</GetScriptBlock>
2151+
<SetScriptBlock>
2152+
&lt;#
2153+
.SYNOPSIS
2154+
Sets the duration
2155+
.DESCRIPTION
2156+
Sets the default duration used for morphs and other animations.
2157+
#&gt;
2158+
param(
2159+
# The value to set
2160+
$value
2161+
)
2162+
2163+
foreach ($v in $value) {
2164+
if ($v -is [Timespan]) {
2165+
$this | Add-Member NoteProperty '.Duration' $v -Force
2166+
} elseif ($v -is [double] -or $v -is [int]) {
2167+
$this | Add-Member NoteProperty '.Duration' ([TimeSpan]::FromSeconds($v)) -Force
2168+
} else {
2169+
Write-Warning "'$Value' is not a number or timespan"
2170+
}
2171+
}
2172+
2173+
2174+
</SetScriptBlock>
2175+
</ScriptProperty>
21392176
<ScriptProperty>
21402177
<Name>Fill</Name>
21412178
<GetScriptBlock>
@@ -2491,6 +2528,11 @@ $newAnimation = @(foreach ($animation in $PathAnimation) {
24912528
if ($animationCopy['attributeName'] -eq 'transform') {
24922529
$elementName = 'animateTransform'
24932530
}
2531+
2532+
2533+
if (-not $animationCopy['dur'] -and $this.Duration) {
2534+
$animationCopy['dur'] = "$($this.Duration.TotalSeconds)s"
2535+
}
24942536

24952537
"&lt;$elementName $(
24962538
@(foreach ($key in $animationCopy.Keys) {

0 commit comments

Comments
 (0)