Created
October 24, 2013 11:13
-
-
Save anonymous/7135317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; #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