Skip to content

Instantly share code, notes, and snippets.

/gist:7135317

Created Oct 24, 2013
Embed
What would you like to do?
; #FUNCTION# ======================================================================================
; Name...........: _ColorSetRGB
; Description ...: Returns the RGB color to work with (COLORREF).
; Syntax.........: _ColorSetRGB($aColor)
; Parameters ....: $aColor - an array of values in the range 0-255:
; [0] Red component color
; [1] Green component color
; [2] Blue component color
; Return values .: Success - returns the RGB color to work with (hexadecimal code).
; Failure - set @error to:
; @error - 1 invalid array
; 2 invalid color value
; Author ........: jpm
; Modified.......:
; Remarks .......: @extended is preserved
; Related .......: _ColorGetRGB
; Link ..........:
; Example .......:
; =================================================================================================
Func _ColorSetRGB($aColor, $curExt = @extended)
If UBound($aColor) <> 3 Then Return SetError(1, 0, -1) ; invalid array
Local $nColor = 0, $iColor
For $i = 0 To 2
$nColor = BitShift($nColor, -8)
$iColor = $aColor[$i]
If $iColor < 0 Or $iColor > 255 Then Return SetError(2, 0, -1) ; invalid color value
$nColor += $iColor
Next
Return SetExtended($curExt, $nColor)
EndFunc ;==>_ColorSetRGB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.