Update 2 Features:
-Accepts, stores, and saves values! (New)
-Shows RGB addition by seperating each color.
-Allows two colors to be saved
-Easily switches between the two colors using radio buttons.
-Writes rgb values of both to an ini file (or modify it to do something else)
-Updates the color demos dynamically, not on release of mouse.
-Tested bug-free on WinXp Pro
-Fast rendering (not a generated bitmap demo, yet a custom colored 100% progress bar!)
Limitations:
-No HSV, HSL support (maybe future work? ...anyone know how?)
Code:
; Language: English
; Platform: Win9x/NT/XP
; Author: A.D.Stokes <stokes91@gmail.com>
; Alias: 1991
; Basic color picker without HSV\HSL\etc. conversion.
if colorpickincluded<>1
{
colorpickincluded=0
}
opencolorbox:
Gui,3:destroy
iniread, Set1R, colorpick.ini, color1, Red
iniread, Set1G, colorpick.ini, color1, Green
iniread, Set1B, colorpick.ini, color1, Blue
iniread, Set2R, colorpick.ini, color2, Red
iniread, Set2G, colorpick.ini, color2, Green
iniread, Set2B, colorpick.ini, color2, Blue
color1all=%Set1R%%Set1G%%Set1B%
color2all=%Set2R%%Set2G%%Set2B%
Gui, 3:Add, Button, x128 y283 w66 h23 , OK
Gui, 3:Add, Button, x200 y283 w66 h23 , Cancel
Gui, 3:Add, Slider, x6 y15 w256 h30 vRedS Range0-255,0x%Set1R%
Gui, 3:Add, Text, x144 y50 w36 h15, &Red:
Gui, 3:Add, Text, x183 y50 w27 h20 vRedU cRed,
Gui, 3:Add, Slider, x6 y75 w256 h30 vGreenS Range0-255,0x%Set1G%
Gui, 3:Add, Text, x144 y110 w36 h15, &Green:
Gui, 3:Add, Text, x183 y110 w27 h20 vGreenU cGreen,
Gui, 3:Add, Slider, x6 y135 w256 h30 vBlueS Range0-255,0x%Set1B%
Gui, 3:Add, Text, x144 y170 w36 h15, Bl&ue:
Gui, 3:Add, Text, x183 y170 w27 h20 vBlueU cBlue,
Gui, 3:Add, Text, x195 y203 w50 h20, Red
Gui, 3:Add, Progress, x169 y203 w20 h20 vRedT cRed, 100
Gui, 3:Add, Text, x195 y223 w50 h20, Green
Gui, 3:Add, Progress, x169 y223 w20 h20 vGreenT cGreen, 100
Gui, 3:Add, Text, x195 y243 w50 h20, Blue
Gui, 3:Add, Progress, x169 y243 w20 h20 vBlueT cBlue, 100
Gui, 3:Add, Radio, x18 y254 w55 h20 vColor1 +checked gchangecolor, Color 1
Gui, 3:Add, Radio, x78 y254 w55 h20 gchangecolor, Color 2
Gui, 3:Add, Progress, x14 y210 w60 h40 vAllT c%color1all%, 100
Gui, 3:Add, Progress, x74 y210 w60 h40 vAllV c%color2all%, 100
Gui, 3:Show, x223 y232 w274 h311, Color Selector
setTimer, checkcolors, 100
Return
checkcolors:
gui, 3:submit,nohide
if Color1 = 1
selectedradio=T
else
selectedradio=V
setformat, integer, D
RedS:=RedS+0
GreenS:=GreenS+0
BlueS:=BlueS+0
HexRedS:=toHex(RedS,2)
HexGreenS:=toHex(GreenS,2)
HexBlueS:=toHex(BlueS,2)
Guicontrol, 3:+c%HexRedS%0000, RedT
Guicontrol, 3:+c00%HexGreenS%00, GreenT
Guicontrol, 3:+c0000%HexBlueS%, BlueT
Guicontrol, 3:+c%HexRedS%%HexGreenS%%HexBlueS%, All%selectedradio%
Guicontrol, 3:, BlueU, %BlueS%
Guicontrol, 3:, GreenU, %GreenS%
Guicontrol, 3:, RedU, %RedS%
Set%color1%R=%HexRedS%
Set%color1%G=%HexGreenS%
Set%color1%B=%HexBlueS%
return
changecolor:
gui, 3:submit,nohide
colorR:=Set%color1%R
colorG:=Set%color1%G
colorB:=Set%color1%B
Guicontrol, 3:, RedS, 0x%ColorR%
Guicontrol, 3:, GreenS, 0x%ColorG%
Guicontrol, 3:, BlueS, 0x%ColorB%
return
3ButtonOk:
if colorpickincluded=1
{
color1out=%Set1R%%Set1G%%Set1B%
color2out=%Set2R%%Set2G%%Set2B%
}
iniwrite, %Set1R%, colorpick.ini, Color1, Red
iniwrite, %Set1G%, colorpick.ini, Color1, Green
iniwrite, %Set1B%, colorpick.ini, Color1, Blue
iniwrite, %Set2R%, colorpick.ini, Color2, Red
iniwrite, %Set2G%, colorpick.ini, Color2, Green
iniwrite, %Set2B%, colorpick.ini, Color2, Blue
gui,3: cancel
gosub,update%colorpickincluded%
return
3ButtonCancel:
gui,3: cancel
if colorpickincluded=1
{
color1out=NULL
color2out=NULL
}
gosub,update%colorpickincluded%
return
3GuiClose:
gosub,update%colorpickincluded%
return
update0:
exitapp
return
toHex(input,padding=0)
{
setformat,integer,H
input:=input+0
if padding>=1
{
stringtrimleft, input, input, 2
stringlen, length, input
toadd:=padding-length
if toadd>=1
{
loop, %toadd%
{
input=0%input%
}
}
}
return %input%
}
This update now allows for easier compatibility with more gui windows, and also SAVES the info.