BananaFredSoft Posted February 24, 2008 Share Posted February 24, 2008 I have a program that deals with a brightness reading from a sensor. The brightness is 0 (black) to 100 (white). Is there a way I can convert this to a hex RGB color that I can use to, for example, set the background of a GUI as? Thanks. I tried this and it didn't really work: 0x & Hex($array[$i], 2) & Hex($array[$i], 2) & Hex($array[$i], 2) -ColinSite:www.bananafredsoft.comStuff:Simple Text Editor - MediaPlayer - Animator - BananaDB - BananaNotes - Chatta - Filesearch - Excuse GeneratorMy YouTube channel:http://www.youtube.com/user/colipat Link to comment Share on other sites More sharing options...
Tomb Posted February 24, 2008 Share Posted February 24, 2008 (edited) ~ Edited February 24, 2008 by Tomb616 Link to comment Share on other sites More sharing options...
Tomb Posted February 24, 2008 Share Posted February 24, 2008 I have a program that deals with a brightness reading from a sensor. The brightness is 0 (black) to 100 (white). Is there a way I can convert this to a hex RGB color that I can use to, for example, set the background of a GUI as? Thanks. I tried this and it didn't really work: 0x & Hex($array[$i], 2) & Hex($array[$i], 2) & Hex($array[$i], 2) maybe the answer is in here expandcollapse popup#include <GuiConstants.au3> Global $Progress[4], $C_set = 0 $gui = GUICreate("Color handler", 390, 140, -1, -1) GUISetBkColor(0x00FC00, $gui); *********** for testing $Progress[1] = GUICtrlCreateProgress(10, 10, 330, 20) $Progress[2] = GUICtrlCreateProgress(10, 40, 330, 20) $Progress[3] = GUICtrlCreateProgress(10, 70, 330, 20) $Label_4 = GUICtrlCreateLabel("Red", 350, 10, 50, 20) GUICtrlSetColor($Label_4, 0xff0000) $Label_5 = GUICtrlCreateLabel("Green", 350, 40, 60, 20) GUICtrlSetColor($Label_5, 0x00ff00) $Label_6 = GUICtrlCreateLabel("Blue", 350, 70, 50, 20) GUICtrlSetColor($Label_6, 0x0000ff) $Label_7 = GUICtrlCreateLabel("", 50, 110, 350, 20) GUISetState() While GUIGetMsg() <> -3 For $iCC = 1 To 3 If sliderprobar($Progress[$iCC], $Progress[$iCC]) Then GUISetBkColor(setcolor()) Next WEnd Func sliderprobar($prog_name, $prog_ID) $aCPos = GUIGetCursorInfo() $cpos = ControlGetPos($gui, "", $prog_name) If $aCPos[4] = $prog_ID And _IsPressed("01") Then GUICtrlSetData($prog_name, $aCPos[0]/ ($cpos[2] / 100) - 2) Sleep(100) Return 1 EndIf Return 0 EndFunc ;==>sliderprobar Func _IsPressed($s_hexKey, $v_dll = 'user32.dll') Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFunc ;==>_IsPressed Func setcolor() Local $hexnum, $nnum For $iCC = 1 To 3 $hexnum = (255 / 100) * Number(GUICtrlRead($Progress[$iCC])) $nnum &= Hex($hexnum, 2) Next GUICtrlSetData($Label_7, "The color copied to the clipboard is... " & (('0x' & $nnum))) ClipPut('0x' & $nnum) Return Execute('0x' & $nnum) EndFunc ;==>setcolor Link to comment Share on other sites More sharing options...
BananaFredSoft Posted February 24, 2008 Author Share Posted February 24, 2008 maybe the answer is in hereThat works! Thanks ! -ColinSite:www.bananafredsoft.comStuff:Simple Text Editor - MediaPlayer - Animator - BananaDB - BananaNotes - Chatta - Filesearch - Excuse GeneratorMy YouTube channel:http://www.youtube.com/user/colipat Link to comment Share on other sites More sharing options...
Tomb Posted February 24, 2008 Share Posted February 24, 2008 That works! Thanks !sure no problem.i always use that to figure out colors on my gui's.i found it on the forum long ago. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now