Skip to content

Commit 018ac70

Browse files
author
James Brundage
committed
Adding FadeIn Effect (Fixes #112)
1 parent c738603 commit 018ac70

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Effects/FadeIn.OBS.FX.ps1

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
})

0 commit comments

Comments
 (0)