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