| View previous topic :: View next topic |
| Author |
Message |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Jun 28, 2002 10:11 am Post subject: VDS Color Picker... |
|
|
This example displays the 216 HTML compatible colors, and shows
the hex value when you click a color. Also can add "#", "$", "0x",
"#00", "$00", or "0x00" prefix to the selected number, and copy it
to the clipboard.
Hex values for up to 999 colors may be loaded into LIST 1. The current
999 limit may be increased by changing %%digits to a higher number.
For example: "%%digits = 4" would allow 9999 color entries (not sure
why you'd want that many though...).
Set table dimensions with %%table_width and %%table_height
(number of color squares). Everything else (window dimensions
and layout) are created from these and LIST 1 automatically.
NOTE: VDS uses colors with RRGGBB values reversed.
There are two lines in the EVLOOP for color codes. The first
gets the VDS colors (RRGGBB reversed), the second gets the
normal RRGGBB format for HTML colors. If you want the VDS
colors, REM the second one.
_______________________________________________________________________________________________________________________________________________________________________________________
| Code: |
LIST CREATE, 1
LIST CREATE, 2
rem -- Load the 6 RGB variations that are HTML compatible --
LIST ADD, 2, @substr(@hex(0), 3, 4)
LIST ADD, 2, @substr(@hex(51), 3, 4)
LIST ADD, 2, @substr(@hex(102), 3, 4)
LIST ADD, 2, @substr(@hex(153), 3, 4)
LIST ADD, 2, @substr(@hex(204), 3, 4)
LIST ADD, 2, @substr(@hex(255), 3, 4)
rem -- Add all combinations of the RGB values to List 1 (216 colors) --
%x = 0
REPEAT
%y = 0
REPEAT
%z = 0
REPEAT
LIST ADD, 1, $00@item(2,%x)@item(2,%y)@item(2,%z)
%z = @succ(%z)
UNTIL @greater(%z, 5)
%y = @succ(%y)
UNTIL @greater(%y, 5)
%x = @succ(%x)
UNTIL @greater(%x, 5)
LIST CLOSE, 2
rem -- 216 colors, so make this color table 18x12 --
%%table_width = 18
%%table_height = 12
rem -- To increase max colors (999), change %%digits to a higher number.
%%digits = 3
%%width = @sum(@prod(%%table_width, 20), 5)
%%height = @sum(@prod(%%table_height, 20), 5)
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"The 216 HTML Compatible Colors",-1,0,%%width,@sum(%%height, 20)
DIALOG ADD,STYLE,BkGrnd1,,,,BLACK
DIALOG ADD,STYLE,TextStyle,Arial,10,B
%%xx = 0
%%yy = 5
%x = 0
REPEAT
if @greater(%%digits, @len(%x))
REPEAT
%x = "0"%x
UNTIL @equal(@len(%x), %%digits)
end
if @both(@greater(%x, 1), @equal(@mod(%x, %%table_width), 0))
%%yy = @sum(%%yy, 20)
%%xx = 0
end
DIALOG ADD,STYLE,Style%x,,,BC,@item(1, %x),@item(1, @diff(@pred(@count(1)), %x))
DIALOG ADD,TEXT,BkGrnd%x,@pred(%%yy),@sum(@prod(%%xx,20), 4),17,17,,,BkGrnd1
DIALOG ADD,TEXT,Color%x,%%yy,@sum(@prod(%%xx,20), 5),15,15,,,Style%x,CLICK
%%square = Color%x
%%xx = @succ(%%xx)
%x = @succ(%x)
UNTIL @equal(%x, @count(1))
DIALOG ADD,EDIT,E1,%%height,5,88,,,,READONLY,TextStyle
DIALOG ADD,BITBTN,Add1,%%height,95,30,20,,"#"," Add # prefix "
DIALOG ADD,BITBTN,Add1a,%%height,125,30,20,,"#00"," Add #00 prefix "
DIALOG ADD,BITBTN,Add2,%%height,155,30,20,,"$"," Add $ prefix "
DIALOG ADD,BITBTN,Add2a,%%height,185,30,20,,"$00"," Add $00 prefix "
DIALOG ADD,BITBTN,Add3,%%height,215,30,20,,"0x"," Add 0x prefix "
DIALOG ADD,BITBTN,Add3a,%%height,245,30,20,,"0x00"," Add 0x00 prefix "
DIALOG ADD,BITBTN,Copy,%%height,275,40,20,,"Copy"," Copy to clipboard "
DIALOG SHOW
:EVLOOP
DIALOG FOCUS, Copy
WAIT EVENT
%e = @event()
if @equal(@substr(%e, 1, 5), "Color")
DIALOG CLEAR, %%square
%%square = @substr(%e, 1, @diff(@len(%e), 5))
DIALOG SET, %%square, "x"
%%color_hex = @substr(@item(1, @substr(%e, 6,8)), 4, 9)
rem -- REM this line for VDS colors (reversed RRGGBB) --
%%color_hex = @substr(%%color_hex,5,6)@substr(%%color_hex,3,4)@substr(%%color_hex,1,2)
DIALOG SET, E1, %%color_hex
else
goto %e
end
goto EVLOOP
:Add1BUTTON
DIALOG SET, E1, #%%color_hex
goto EVLOOP
:Add1aBUTTON
DIALOG SET, E1, #00%%color_hex
goto EVLOOP
:Add2BUTTON
DIALOG SET, E1, $%%color_hex
goto EVLOOP
:Add2aBUTTON
DIALOG SET, E1, $00%%color_hex
goto EVLOOP
:Add3BUTTON
DIALOG SET, E1, 0x%%color_hex
goto EVLOOP
:Add3aBUTTON
DIALOG SET, E1, 0x00%%color_hex
goto EVLOOP
:CopyBUTTON
CLIPBOARD SET, @dlgtext(E1)
goto EVLOOP
:CLOSE
EXIT
|
EDIT
-Replaced INFO window with an edit box display.
-Added buttons to add "#", "$", or "0x" prefix to selected number.
-Added button to copy number to the clipboard.
-Color now displays a small "x" when clicked.
-Reversed text color (sort of) so "x" is different color.
-Now reverses RGB colors when # is added (thanks to Dread for this info).
-Changed display to overwrite instead of append (thanks again to Dread).
-Can now add "#", "$", "0x", "#00", "$00" or "0x00" prefixes.
-The program now uses the $00 prefix itself to display its' colors,
but omits them from the hex display.
-REVERSED COLORS - VDS uses colors with RRGGBB values reversed,
so I added a second line in the EVLOOP for color codes. The first one
gets the VDS colors (RRGGBB reversed), the second gets the normal
RRGGBB format for HTML colors. If you want the VDS colors, REM the
second one.
-Found/fixed one more bug. Some prefixes would revert back to
VDS BBGGRR color format.
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361

Last edited by Mac on Sat Nov 30, 2002 8:14 pm; edited 19 times in total |
|
| Back to top |
|
 |
LinkSisco Valued Newbie
Joined: 17 May 2002 Posts: 30 Location: UK
|
Posted: Fri Jun 28, 2002 10:32 am Post subject: |
|
|
Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you...
Thats perfect MAC...
I could kiss you, but i wont...
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Jun 28, 2002 11:16 am Post subject: |
|
|
| Code: |
%x = 0
REPEAT
INFO "You're welcome!"
%x = @succ(%x)
UNTIL @greater(%x, 10)
|
Glad you like it.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Jun 29, 2002 3:13 am Post subject: |
|
|
Made some code changes you might want to check out...
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sat Jun 29, 2002 8:48 am Post subject: |
|
|
Hey Mac!
Nice job there! But I just couldn't help making a couple of changes:
* Renamed buttons
* Fixed the # part to get a useable HTML code
* Let the buttons do an overwrite instead of insert
Greetz
Dr. Dread
| Code: |
LIST CREATE, 1
LIST CREATE, 2
rem -- Load the 6 RGB variations that are HTML compatible --
LIST ADD, 2, @substr(@hex(0), 3, 4)
LIST ADD, 2, @substr(@hex(51), 3, 4)
LIST ADD, 2, @substr(@hex(102), 3, 4)
LIST ADD, 2, @substr(@hex(153), 3, 4)
LIST ADD, 2, @substr(@hex(204), 3, 4)
LIST ADD, 2, @substr(@hex(255), 3, 4)
rem -- Add all combinations of the RGB values to List 1 (216 colors) --
%x = 0
REPEAT
%y = 0
REPEAT
%z = 0
REPEAT
LIST ADD, 1, $@item(2,%x)@item(2,%y)@item(2,%z)
%z = @succ(%z)
UNTIL @greater(%z, 5)
%y = @succ(%y)
UNTIL @greater(%y, 5)
%x = @succ(%x)
UNTIL @greater(%x, 5)
LIST CLOSE, 2
rem -- 216 colors, so make this color table 18x12 --
%%table_width = 18
%%table_height = 12
rem -- To increase max colors (999), change %%digits to a higher number.
%%digits = 3
%%width = @sum(@prod(%%table_width, 20), 5)
%%height = @sum(@prod(%%table_height, 20), 5)
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"The 216 HTML Compatible Colors",-1,0,%%width,@sum(%%height, 20)
DIALOG ADD,STYLE,BkGrnd1,,,,BLACK
DIALOG ADD,STYLE,TextStyle,Arial,10,B
%%xx = 0
%%yy = 5
%x = 0
REPEAT
if @greater(%%digits, @len(%x))
REPEAT
%x = "0"%x
UNTIL @equal(@len(%x), %%digits)
end
if @both(@greater(%x, 1), @equal(@mod(%x, %%table_width), 0))
%%yy = @sum(%%yy, 20)
%%xx = 0
end
DIALOG ADD,STYLE,Style%x,,,BC,@item(1, %x),@item(1, @diff(@pred(@count(1)), %x))
DIALOG ADD,TEXT,BkGrnd%x,@pred(%%yy),@sum(@prod(%%xx,20), 4),17,17,,,BkGrnd1
DIALOG ADD,TEXT,Color%x,%%yy,@sum(@prod(%%xx,20), 5),15,15,,,Style%x,CLICK
%%xx = @succ(%%xx)
%x = @succ(%x)
UNTIL @equal(%x, @count(1))
DIALOG ADD,BUTTON,Add1,%%height,85,50,20,"HTML"
DIALOG ADD,BUTTON,Add2,%%height,138,50,20,"VDS"
DIALOG ADD,BUTTON,Add3,%%height,191,50,20,"HEX"
DIALOG ADD,BUTTON,Copy,%%height,244,110,20,"Copy To Clipboard",,DEFAULT
DIALOG ADD,EDIT,E1,%%height,5,77,,,,READONLY,TextStyle
DIALOG SHOW
%%square = "Color000"
:EVLOOP
DIALOG FOCUS, Copy
WAIT EVENT
%e = @event()
if @equal(@substr(%e, 1, 5), "Color")
DIALOG CLEAR, %%square
%%square = @substr(%e, 1, @diff(@len(%e), 5))
DIALOG SET, %%square, "x"
%%color_hex = @substr(@item(1, @substr(%e, 6,8)), 2, 7)
DIALOG SET, E1, %%color_hex
else
goto %e
end
goto EVLOOP
:Add1BUTTON
%%gethtml = #@substr(%%color_hex,5,6)@substr(%%color_hex,3,4)@substr(%%color_hex,1,2)
DIALOG SET, E1, %%gethtml
goto EVLOOP
:Add2BUTTON
DIALOG SET, E1, $0%%color_hex
goto EVLOOP
:Add3BUTTON
DIALOG SET, E1, 0x%%color_hex
goto EVLOOP
:CopyBUTTON
CLIPBOARD SET, @dlgtext(E1)
goto EVLOOP
:CLOSE
EXIT
|
_________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing
Last edited by Dr. Dread on Fri Nov 29, 2002 6:42 am; edited 3 times in total |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Jun 29, 2002 9:13 am Post subject: |
|
|
Hiya Dread,
Thanks, I was unaware of the HTML "#" situation. I had no idea that
a "#" reversed the RGB colors (I'm not exactly an HTML wizard...).
I changed it in the original posted code.
However, I gotta few questions...
Why add a "$0" to your VDS button routine?
This program uses the same numbers with only a "$" prefix...
And why do an overwrite instead of an insert?
Both give the same results...
Also, you changed the "Add $" button to a "VDS" button,
but VDS isn't the only language that uses a "$" to denote hex...
Thanks again for the "#" info.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sat Jun 29, 2002 11:00 am Post subject: |
|
|
| Quote: | Why add a "$0" to your VDS button routine?
This program uses the same numbers with only a "$" prefix... |
Maybe I just didn't remember things right - thought that VDS used an extra 0.
| Quote: | And why do an overwrite instead of an insert?
Both give the same results... |
I just changed insert to overwrite, because when you experiment a little with the buttons
or press the wrong one first, the output field will get a bit messed up. Really just a triviality.
| Quote: | Also, you changed the "Add $" button to a "VDS" button,
but VDS isn't the only language that uses a "$" to denote hex... |
You're right. I just changed it to VDS because that's the only language that I use for this kind
of stuff.
| Quote: | | Thanks again for the "#" info. |
Don't mention it.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing
Last edited by Dr. Dread on Fri Nov 29, 2002 6:41 am; edited 1 time in total |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Sat Jun 29, 2002 12:39 pm Post subject: |
|
|
From the Microsoft's SDK helpfiles:
| Quote: | When specifying an explicit RGB color, the COLORREF value has the following hexadecimal form:
0x00bbggrr
The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green; and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF. |
Also the Delphi 4 helpfile states:
| Quote: | If you specify TColor as a specific 4-byte hexadecimal number instead of using the constants defined in the Graphics unit, the low three bytes represent RGB color intensities for blue, green, and red, respectively. The value $00FF0000 represents full-intensity, pure blue, $0000FF00 is pure green, and $000000FF is pure red. $00000000 is black and $00FFFFFF is white.
If the highest-order byte is zero ($00), the color obtained is the closest matching color in the system palette. If the highest-order byte is one ($01), the color obtained is the closest matching color in the currently realized palette. If the highest-order byte is two ($02), the value is matched with the nearest color in the logical palette of the current device context. |
So that explains why colors in VDS are usually written as "$00FFFFFF".
Tommy |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Jun 29, 2002 8:47 pm Post subject: |
|
|
| Quote: |
Dr. Dread wrote:
I just changed to insert to overwrite, because when you experiment a
little with the buttons or press the wrong one first, the output field will
get a bit messed up. Really just a triviality.
|
Aha! Thanks again Dread, I hadn't played around with pressing
the buttons multiple times. I changed the code to use %%color_hex
instead of @dlgtext() for the display. BTW, I think it's more than
just a triviality...
| Quote: |
Tommy wrote:
So that explains why colors in VDS are usually written as "$00FFFFFF"
|
OK guys, so should the "$" prefix be changed to "$00"?
Will that work with other programs that use "$" to denote hex?
Or should all the color values be prefixed with "00" to start with?
BTW, I have CuteHTML, and it only uses 6 digit color codes.
I really appreciate all the input on this.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Jun 29, 2002 9:35 pm Post subject: |
|
|
OK, I found a solution to the "00" prefix question...
Now you can add a "#", "$", "0x", "#00", "$00", or "0x00" prefix
to the selected number.
Also, the program itself now uses the "$00" prefix to display its'
colors, but omits the prefix from the displayed number.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Sun Jun 30, 2002 4:12 pm Post subject: |
|
|
It's just a matter of tidyness to include the initial zeros, as color values such as $01445566
or $02445566 may be used as well. Of course as with any numbers, initial zeros could
be safely left away.
Tommy |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu Nov 28, 2002 5:27 pm Post subject: |
|
|
Well, I just discovered this...
REVERSED COLORS - VDS uses colors with RRGGBB values reversed,
so I added a second line in the EVLOOP for HTML color codes. The first
one gets the VDS colors (RRGGBB reversed) into the %%color_hex var,
the second swaps to the normal RRGGBB format for HTML colors.
If you want the VDS colors, REM the second one.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Nov 30, 2002 8:13 pm Post subject: |
|
|
Fixed one more bug. Some prefixes would revert back
to the VDS BBGGRR color format after the last fix.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|