Skip to content

Commit 2359966

Browse files
author
James Brundage
committed
Adding .Crop (Fixes #57)
1 parent f343095 commit 2359966

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

  • Types/OBS.GetSceneItemList.Response
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
$cropTable = [Ordered]@{
2+
cropBottom = 0
3+
cropLeft = 0
4+
cropRight = 0
5+
cropTop = 0
6+
}
7+
8+
$MatchingKey = [Regex]::new("(?>$(
9+
@($cropTable.Keys -join '|'
10+
'|'
11+
$cropTable.Keys -replace '^crop' -join '|') -join ''
12+
))", 'IgnoreCase')
13+
14+
15+
$currentKey = ''
16+
foreach ($arg in $args) {
17+
if ($arg -is [Collections.IDictionary]) {
18+
foreach ($keyValue in $arg.GetEnumerator()) {
19+
if ($keyValue.Key -match $MatchingKey) {
20+
$cropTable[$matches.0 -replace '^crop' -replace '^', 'crop'] = $keyValue.Value
21+
}
22+
}
23+
}
24+
if ($arg -is [string] -and $arg -match $MatchingKey) {
25+
$currentKey = $matches.0 -replace '^crop' -replace '^', 'crop'
26+
}
27+
if ($arg -is [int] -and $currentKey) {
28+
$cropTable[$currentKey] = $arg
29+
$currentKey = ''
30+
}
31+
}
32+
33+
$this | Set-OBSSceneItemTransform -SceneItemTransform $cropTable

0 commit comments

Comments
 (0)