File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <#
2+ . SYNOPSIS
3+ Fades out
4+ . DESCRIPTION
5+ Fades an input by animating an input's opacity.
6+ #>
7+ param (
8+ # The name of the input
9+ [string ]$InputName ,
10+
11+ # The duration (by default, one second)
12+ [timespan ]$Duration = " 00:00:01"
13+ )
14+
15+ if (-not $InputName -and $this -and $this.InputName ) {
16+ $InputName = $this.InputName
17+ }
18+
19+ if (-not $InputName -and $this -and $this.SourceName ) {
20+ $InputName = $this.SourceName
21+ }
22+
23+ if (-not $InputName ) { return }
24+
25+ $addedFilter = Add-OBSColorFilter - FilterName " FadeOut" - SourceName $InputName
26+
27+ # We want to have roughly two steps per frame
28+ $StepCount = [Math ]::Ceiling($Duration.TotalMilliseconds / ([timespan ]::fromSeconds(1 / 30 ).TotalMilliseconds)) * 2
29+
30+ $stepSleep = $Duration.TotalMilliseconds / $StepCount
31+
32+ $opacity = 1
33+ $stepOpacity = [double ]1 / $StepCount
34+ @ (foreach ($stepNum in 1 .. $StepCount ) {
35+ $opacity -= $stepOpacity
36+ Set-OBSColorFilter - FilterName " FadeOut" - SourceName $InputName - Opacity $opacity - PassThru
37+ Send-OBSSleep - SleepMillis $stepSleep - PassThru
38+ })
You can’t perform that action at this time.
0 commit comments