#include <Misc.au3>
#include <Color.au3>
#Include <BigNum.au3>
#include <WinAPI.au3>
#include <SliderConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
Local $nColor = '0xFF00FF'
Local $RGB = _ColorGetRGB($nColor)
Local $R = _ColorGetRed($nColor)
Local $G = _ColorGetGreen($nColor)
Local $B = _ColorGetBlue($nColor)
Local $gui1 = GUICreate('', 420, 250, Default, Default, -1, $WS_EX_COMPOSITED)
Local $but1 = GUICtrlCreateButton('Choose Color', 350, 175, 60, 60, $BS_MULTILINE)
Local $but2 = GUICtrlCreateButton('Res', 315, 175, 25, 60)
Local $sld0 = GUICtrlCreateSlider(100, 170, 185, 25, $TBS_NOTICKS, $WS_EX_TRANSPARENT)
Local $sld1 = GUICtrlCreateSlider(100, 190, 185, 25, $TBS_NOTICKS, $WS_EX_TRANSPARENT)
Local $sld2 = GUICtrlCreateSlider(100, 210, 185, 25, $TBS_NOTICKS, $WS_EX_TRANSPARENT)
GUICtrlCreateGroup('Tupe', 10, 165, 50, 75)
Local $Chck1 = GUICtrlCreateRadio('(HSL)', 15, 185)
GUICtrlSetState(-1, $GUI_CHECKED)
Local $Chck2 = GUICtrlCreateRadio('(%)', 15, 210)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Type = 1
$HSL = _ColorConvertRGBtoHSL($RGB)
Local $H = $HSL[0]
Local $S = $HSL[1]
Local $L = $HSL[2]
GUICtrlCreateLabel('Hue', 70, 170, 50)
GUICtrlCreateLabel('Satur', 70, 190, 50)
GUICtrlCreateLabel('Brigh', 70, 210, 50)
GUICtrlSetLimit($sld0, 239)
GUICtrlSetData($sld0, $H)
GUICtrlSetLimit($sld1, 240)
GUICtrlSetData($sld1, $S)
GUICtrlSetLimit($sld2, 240)
GUICtrlSetData($sld2, $L)
GUICtrlSetBkColor($sld0, $nColor)
GUICtrlSetBkColor($sld1, $nColor)
GUICtrlSetBkColor($sld2, $nColor)
GUISetBkColor($nColor, $gui1)
GUISetState()
Local $lab0 = GUICtrlCreateLabel($H, 285, 170, 30)
Local $lab1 = GUICtrlCreateLabel($S, 285, 190, 30)
Local $lab2 = GUICtrlCreateLabel($L, 285, 210, 30)
GUICtrlCreateGroup('Original color', 10, 5, 190, 155)
Local $lab3 = GUICtrlCreateLabel('RGB: ', 30, 30, 24, 15)
Local $lab4 = GUICtrlCreateLabel('HEX: ', 30, 50, 24, 15)
Local $In1 = GUICtrlCreateInput($R, 70, 27, 35, 18)
Local $In01 = GUICtrlCreateInput($G, 107, 27, 35, 18)
Local $In001 = GUICtrlCreateInput($B, 144, 27, 35, 18)
Local $In2 = GUICtrlCreateInput($nColor, 106, 48, 73, 18)
GUICtrlCreateLabel('Hue: ', 30, 89, 70, 15)
GUICtrlCreateLabel('Saturation: ', 30, 110, 70, 15)
GUICtrlCreateLabel('Brightness: ', 30, 131, 70, 15)
GUICtrlCreateLabel('%%', 112, 68, 30, 13)
GUICtrlCreateLabel('HSL', 149, 68, 30, 13)
Local $In5 = GUICtrlCreateInput($HSL[0], 144, 85, 35, 18); Hue (HSL)
Local $In05 = GUICtrlCreateInput(_BigNum_Round($HSL[0]*1.25, 0), 107, 85, 35, 18);Hue (%)
Local $In3 = GUICtrlCreateInput($HSL[1], 144, 107, 35, 18);Saturation (HSL)
Local $In03 = GUICtrlCreateInput($HSL[1]/1.2, 107, 107, 35, 18);Saturation (%)
Local $In4 = GUICtrlCreateInput($HSL[2], 144, 129, 35, 18);Brightness (HSL)
Local $In04 = GUICtrlCreateInput($HSL[2]/1.2, 107, 129, 35, 18);Brightness (%)
GUICtrlCreateGroup('Modified color', 220, 5, 190, 155)
Local $lab3_1 = GUICtrlCreateLabel('RGB: ', 240, 30, 24, 15)
Local $lab4_1 = GUICtrlCreateLabel('HEX: ', 240, 50, 24, 15)
Local $In1_1 = GUICtrlCreateInput($R, 280, 27, 35, 18)
Local $In01_1 = GUICtrlCreateInput($G, 317, 27, 35, 18)
Local $In001_1 = GUICtrlCreateInput($B, 354, 27, 35, 18)
Local $In2_1 = GUICtrlCreateInput($nColor, 316, 48, 73, 18)
GUICtrlCreateLabel('Hue: ', 240, 89, 70, 15)
GUICtrlCreateLabel('Saturation: ', 240, 110, 70, 15)
GUICtrlCreateLabel('Brightness: ', 240, 131, 70, 15)
GUICtrlCreateLabel('%%', 322, 68, 30, 13)
GUICtrlCreateLabel('HSL', 359, 68, 30, 13)
Local $In5_1 = GUICtrlCreateInput($HSL[0], 354, 85, 35, 18); Hue (HSL)
Local $In05_1 = GUICtrlCreateInput(_BigNum_Round($HSL[0]*1.25, 0), 317, 85, 35, 18);Hue (%)
Local $In3_1 = GUICtrlCreateInput($HSL[1], 354, 107, 35, 18);Saturation (HSL)
Local $In03_1 = GUICtrlCreateInput(_BigNum_Round($HSL[1]/1.2, 0), 317, 107, 35, 18);Saturation (%)
Local $In4_1 = GUICtrlCreateInput($HSL[2], 354, 129, 35, 18);Brightness (HSL)
Local $In04_1 = GUICtrlCreateInput(_BigNum_Round($HSL[2]/1.2, 0), 317, 129, 35, 18);Brightness (%)
Do
Switch GUIGetMsg()
Case $but1
$nColor = _ChooseColor(2, $nColor, 2, $gui1)
If Not @error Then
$RGB = _ColorGetRGB($nColor)
Update($nColor, $Type)
If $Type = 2 Then
$H = 0
$S = 0
$L = 0
GUICtrlSetData($sld0, 0)
GUICtrlSetData($sld1, 0)
GUICtrlSetData($sld2, 0)
EndIf
EndIf
Case $In2
$nColor = GUICtrlRead($In2)
Update($nColor, $Type)
_SetColorParam($H, $S, $L, $nColor, $Type)
Case $Chck1
$Type = 1
Update($nColor, $Type)
Case $Chck2
$Type = 2
$H = 0
$S = 0
$L = 0
GUICtrlSetData($sld0, $H & '%')
GUICtrlSetData($sld1, $S & '%')
GUICtrlSetData($sld2, $L & '%')
Update($nColor, $Type)
Case $but2
If $Type = 2 Then
$H = 0
$S = 0
$L = 0
GUICtrlSetData($sld0, 0)
GUICtrlSetData($sld1, 0)
GUICtrlSetData($sld2, 0)
EndIf
Update($nColor, $Type)
Case -3
Exit
EndSwitch
if $H <> GUICtrlRead($sld0) Or $S <> GUICtrlRead($sld1) or $L <> GUICtrlRead($sld2) Then
ConsoleWrite('Before: Set H: ' & $H & ', Set S: ' & $S & ', Set L: ' & $L & @CR)
$H = _BigNum_Round(GUICtrlRead($sld0), 0)
$S = _BigNum_Round(GUICtrlRead($sld1), 0)
$L = _BigNum_Round(GUICtrlRead($sld2), 0)
$Color = _SetColorParam($H, $S, $L, $nColor, $Type)
Update($Color, $Type)
EndIf
Sleep(1)
Until 0
Func Update($Color, $Type)
$RGB = _ColorGetRGB($Color)
$HSL = _ColorConvertRGBtoHSL($RGB)
$_H = _BigNum_Round($HSL[0], 0)
$_S = _BigNum_Round($HSL[1], 0)
$_L = _BigNum_Round($HSL[2], 0)
If $Type = 1 Then
GUICtrlSetLimit($sld0, 239)
GUICtrlSetLimit($sld1, 240)
GUICtrlSetLimit($sld2, 240)
GUICtrlSetData($lab0, $_H)
GUICtrlSetData($lab1, $_S)
GUICtrlSetData($lab2, $_L)
GUICtrlSetData($sld0, $_H)
GUICtrlSetData($sld1, $_S)
GUICtrlSetData($sld2, $_L)
ElseIf $Type = 2 Then
GUICtrlSetData($lab0, $H & '%')
GUICtrlSetData($lab1, $S & '%')
GUICtrlSetData($lab2, $L & '%')
GUICtrlSetLimit($sld0, 100, -100)
GUICtrlSetLimit($sld1, 100, -100)
GUICtrlSetLimit($sld2, 100, -100)
EndIf
GUISetBkColor($Color, $gui1)
$R = _BigNum_Round($RGB[0], 0)
$G = _BigNum_Round($RGB[1], 0)
$B = _BigNum_Round($RGB[2], 0)
GUICtrlSetData($In1_1, $R)
GUICtrlSetData($In01_1, $G)
GUICtrlSetData($In001_1, $B)
GUICtrlSetData($In2_1, $Color)
GUICtrlSetBkColor($sld0, $Color)
GUICtrlSetBkColor($sld1, $Color)
GUICtrlSetBkColor($sld2, $Color)
GUICtrlSetData($In3_1, $_S);Saturation (HSL)
GUICtrlSetData($In4_1, $_L);Brightness (HSL)
GUICtrlSetData($In03_1, _BigNum_Round($_S/1.2, 0));Saturation (%)
GUICtrlSetData($In04_1, _BigNum_Round($_L/1.2, 0));Brightness (%)
GUICtrlSetData($In5_1, $_H); Hue (HSL)
GUICtrlSetData($In05_1, _BigNum_Round($_H*1.25,0)); Hue (%)
$RGB = _ColorGetRGB($nColor)
$HSL = _ColorConvertRGBtoHSL($RGB)
$__H = _BigNum_Round($HSL[0], 0)
$__S = _BigNum_Round($HSL[1], 0)
$__L = _BigNum_Round($HSL[2], 0)
GUICtrlSetData($In03, _BigNum_Round($__S/1.2, 0));Saturation (%)
GUICtrlSetData($In04, _BigNum_Round($__L/1.2, 0));Brightness (%)
GUICtrlSetData($In05, _BigNum_Round($__H*1.25,0)); Hue (%)
GUICtrlSetData($In3, $__S);Saturation (HSL)
GUICtrlSetData($In4, $__L);Brightness (HSL)
GUICtrlSetData($In5, $__H); Hue (HSL)
$R = _BigNum_Round($RGB[0], 0)
$G = _BigNum_Round($RGB[1], 0)
$B = _BigNum_Round($RGB[2], 0)
GUICtrlSetData($In1, $R)
GUICtrlSetData($In01, $G)
GUICtrlSetData($In001, $B)
GUICtrlSetData($In2, $nColor)
EndFunc
Func _SetColorParam($H, $S, $L, $lColor, $Type)
$_RGB = _ColorGetRGB($lColor)
$HSL = _ColorConvertRGBtoHSL($_RGB)
If $Type = 2 Then
$_H = $H
$_S = $S
$_L = $L
$H = $HSL[0]
$S = $HSL[1]
$L = $HSL[2]
If $_H = 0 Then $H = $HSL[0]
If $_S = 0 Then $S = $HSL[1]
If $_L = 0 Then $L = $HSL[2]
If $_H > 0 Then $H = $H + (((239 - $H) / 100) * $_H)
If $_S > 0 Then $S = $S + (((240 - $S) / 100) * $_S)
If $_L > 0 Then $L = $L + (((240 - $L) / 100) * $_L)
If $_H < 0 Then $H = $H + ($H / 100) * $_H
If $_S < 0 Then $S = $S + ($S / 100) * $_S
If $_L < 0 Then $L = $L + ($L / 100) * $_L
ElseIf $Type = 1 Then
If $H = -1 Then $H = $HSL[0]
If $S = -1 Then $S = $HSL[1]
If $L = -1 Then $L = $HSL[2]
EndIf
Local $HSL[3] = [_BigNum_Round($H, 0), _BigNum_Round($S, 0), _BigNum_Round($L, 0)]
$_RGB = _ColorConvertHSLtoRGB($HSL)
$R = _BigNum_Round($_RGB[0], 0)
$G = _BigNum_Round($_RGB[1], 0)
$B = _BigNum_Round($_RGB[2], 0)
$lColor= '0x' & StringFormat("%02X%02X%02X", $R, $G, $B)
Return $lColor
EndFunc