Skip to content

Commit 963719f

Browse files
StartAutomatingStartAutomating
authored andcommitted
Merge branch 'obs-powershell-updates' of https://github.com/StartAutomating/obs-powershell into obs-powershell-updates
1 parent 4700b8c commit 963719f

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

obs-powershell.types.ps1xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,45 @@ $this |
1717

1818
</Script>
1919
</ScriptMethod>
20+
<ScriptMethod>
21+
<Name>Crop</Name>
22+
<Script>
23+
$cropTable = [Ordered]@{
24+
cropBottom = 0
25+
cropLeft = 0
26+
cropRight = 0
27+
cropTop = 0
28+
}
29+
30+
$MatchingKey = [Regex]::new("(?&gt;$(
31+
@($cropTable.Keys -join '|'
32+
'|'
33+
$cropTable.Keys -replace '^crop' -join '|') -join ''
34+
))", 'IgnoreCase')
35+
36+
37+
$currentKey = ''
38+
foreach ($arg in $args) {
39+
if ($arg -is [Collections.IDictionary]) {
40+
foreach ($keyValue in $arg.GetEnumerator()) {
41+
if ($keyValue.Key -match $MatchingKey) {
42+
$cropTable[$matches.0 -replace '^crop' -replace '^', 'crop'] = $keyValue.Value
43+
}
44+
}
45+
}
46+
if ($arg -is [string] -and $arg -match $MatchingKey) {
47+
$currentKey = $matches.0 -replace '^crop' -replace '^', 'crop'
48+
}
49+
if ($arg -is [int] -and $currentKey) {
50+
$cropTable[$currentKey] = $arg
51+
$currentKey = ''
52+
}
53+
}
54+
55+
$this | Set-OBSSceneItemTransform -SceneItemTransform $cropTable
56+
57+
</Script>
58+
</ScriptMethod>
2059
<ScriptMethod>
2160
<Name>Delete</Name>
2261
<Script>

0 commit comments

Comments
 (0)