Skip to content

Commit 5aaa3bb

Browse files
feat: Turtle.Duration ( Fixes #153 )
1 parent f34f17c commit 5aaa3bb

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

Types/Turtle/get_Duration.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<#
2+
.SYNOPSIS
3+
Gets the duration
4+
.DESCRIPTION
5+
Gets the default duration of animations and morphs.
6+
#>
7+
if ($this.'.Duration') { return $this.'.Duration'}
8+
return

Types/Turtle/set_Duration.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<#
2+
.SYNOPSIS
3+
Sets the duration
4+
.DESCRIPTION
5+
Sets the default duration used for morphs and other animations.
6+
#>
7+
param(
8+
# The value to set
9+
$value
10+
)
11+
12+
foreach ($v in $value) {
13+
if ($v -is [Timespan]) {
14+
$this | Add-Member NoteProperty '.Duration' $v -Force
15+
} elseif ($v -is [double] -or $v -is [int]) {
16+
$this | Add-Member NoteProperty '.Duration' ([TimeSpan]::FromSeconds($v)) -Force
17+
} else {
18+
Write-Warning "'$Value' is not a number or timespan"
19+
}
20+
}
21+

Types/Turtle/set_PathAnimation.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ $newAnimation = @(foreach ($animation in $PathAnimation) {
3636
if ($animationCopy['attributeName'] -eq 'transform') {
3737
$elementName = 'animateTransform'
3838
}
39+
40+
41+
if (-not $animationCopy['dur'] -and $this.Duration) {
42+
$animationCopy['dur'] = "$($this.Duration.TotalSeconds)s"
43+
}
3944

4045
"<$elementName $(
4146
@(foreach ($key in $animationCopy.Keys) {

0 commit comments

Comments
 (0)