Skip to content

Commit efff5ea

Browse files
Merge pull request #115 from I-Am-Jakoby/patch-1
FadeOut Effect (Fixes #114)
2 parents 01aea23 + 59b4526 commit efff5ea

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Effects/FadeOut.OBS.FX.ps1

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
})

0 commit comments

Comments
 (0)