@@ -107,4 +107,70 @@ $this | Set-OBSSceneItemTransform -SceneItemTransform ([PSCustomObject][Ordered]
107107 </ScriptProperty >
108108 </Members >
109109 </Type >
110+ <Type >
111+ <Name >OBS.Input.Color.Source.V3</Name >
112+ <Members >
113+ <ScriptMethod >
114+ <Name >SetColor</Name >
115+ <Script >
116+ param(
117+ [ValidatePattern('\#(?> [0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})')]
118+ [string]
119+ $Color
120+ )
121+
122+ $hexChar = [Regex]::new('[0-9a-f]')
123+ $hexColors = @($hexChar.Matches($Color))
124+
125+ switch ($hexColors.Length) {
126+ 8 {
127+ #full rgba
128+ $alpha = [byte]::Parse($hexColors[0..1] -join '', 'HexNumber')
129+ $red = [byte]::Parse($hexColors[2..3] -join '', 'HexNumber')
130+ $green = [byte]::Parse($hexColors[4..5] -join '', 'HexNumber')
131+ $blue = [byte]::Parse($hexColors[6..7] -join '', 'HexNumber')
132+ }
133+ 6 {
134+ #rgb only, assume ff for alpha
135+ $alpha = 0xff
136+ $red = [byte]::Parse($hexColors[0..1] -join '', 'HexNumber')
137+ $green = [byte]::Parse($hexColors[2..3] -join '', 'HexNumber')
138+ $blue = [byte]::Parse($hexColors[4..5] -join '', 'HexNumber')
139+ }
140+ 4 {
141+ #short rgba
142+ $alpha = [byte]::Parse(($hexColors[0],$hexColors[0] -join ''), 'HexNumber')
143+ $red = [byte]::Parse(($hexColors[1],$hexColors[1] -join ''), 'HexNumber')
144+ $green = [byte]::Parse(($hexColors[2],$hexColors[2] -join ''), 'HexNumber')
145+ $blue = [byte]::Parse(($hexColors[3],$hexColors[3] -join ''), 'HexNumber')
146+ }
147+ 3 {
148+ #short rgb, assume f for alpha
149+ $alpha = 0xff
150+ $red = [byte]::Parse(($hexColors[0],$hexColors[0] -join ''), 'HexNumber')
151+ $green = [byte]::Parse(($hexColors[1],$hexColors[1] -join ''), 'HexNumber')
152+ $blue = [byte]::Parse(($hexColors[2],$hexColors[2] -join ''), 'HexNumber')
153+ }
154+ 0 {
155+ # No color provided, default to transparent black
156+ $alpha = 0
157+ $red = 0
158+ $green = 0
159+ $blue = 0
160+ }
161+ }
162+
163+ $hexColor = ("{0:x2}{1:x2}{2:x2}{3:x2}" -f $alpha, $blue, $green, $red)
164+
165+ $realColor = [uint32]::Parse($hexColor,'HexNumber')
166+
167+ $this | Set-OBSInputSettings -InputSettings ([Ordered]@{color=$realColor})
168+
169+
170+
171+
172+ </Script >
173+ </ScriptMethod >
174+ </Members >
175+ </Type >
110176</Types >
0 commit comments