| View previous topic :: View next topic |
| Author |
Message |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Tue Aug 13, 2002 10:29 pm Post subject: Hex back to RGB? |
|
|
Ok, I know how to take RGB and get to HEX with it, but for the life
of me, I can't figure out how to reverse it back to RGB.....
Anyone have any idea's or clue's for me on this one??
Thanks in advance,
-Garrett
Last edited by Garrett on Wed Aug 14, 2002 6:38 pm; edited 1 time in total |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Aug 13, 2002 10:37 pm Post subject: |
|
|
Take each RGB hex value (individually), and do this:
@sum($%%value, 0)
This converts it back to decimal.
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 Tue Aug 13, 2002 10:39 pm; edited 2 times in total |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Tue Aug 13, 2002 10:37 pm Post subject: |
|
|
Depending on what you're trying to do, the following code will show useful things:
| Code: |
%%vdscolor = @sum($00123456,0)
%%hex = @hex(%%vdscolor,8)
%%blue = @sum($@substr(%%hex,3,4),0)
%%green = @sum($@substr(%%hex,5,6),0)
%%red = @sum($@substr(%%hex,7,8),0)
info VDS color: %%vdscolor@cr()Hex color: %%hex@cr()Red: %%red@cr()Green: %%green@cr()Blue: %%blue
|
|
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed Aug 14, 2002 6:39 pm Post subject: |
|
|
Mac, Tommy, Thanks a bunch.
-Garrett |
|
| Back to top |
|
 |
Tsunami1988 Contributor


Joined: 15 Aug 2002 Posts: 70 Location: The Netherlands
|
Posted: Fri Aug 16, 2002 12:16 pm Post subject: RGB to HEX |
|
|
Can someone tell me how to convert a color value from the registry (ex. 0 78 152) to HEX? (does VDS 3.51 understand HEX?)
Erik |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Aug 16, 2002 5:17 pm Post subject: |
|
|
Yes, you can use the @hex() function.
While @format() will limit numbers to the length supplied, it
will NOT add leading zeros if the string is shorter, so you
must modify string length to get 2 digit RGB hex values.
| Code: |
%%num1 = 0
if @greater(2, @len(@format(@hex(%%num1), 2.0)))
%%num1 = "0"@format(@hex(%%num1), 2.0)
else
%%num1 = @format(@hex(%%num1), 2.0)
end
%%num2 = 78
if @greater(2, @len(@format(@hex(%%num2), 2.0)))
%%num2 = "0"@format(@hex(%%num2), 2.0)
else
%%num2 = @format(@hex(%%num2), 2.0)
end
%%num3 = 152
if @greater(2, @len(@format(@hex(%%num3), 2.0)))
%%num3 = "0"@format(@hex(%%num3), 2.0)
else
%%num3 = @format(@hex(%%num3), 2.0)
end
INFO %%num1%%num2%%num3
|
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 |
|
 |
Tsunami1988 Contributor


Joined: 15 Aug 2002 Posts: 70 Location: The Netherlands
|
Posted: Fri Aug 16, 2002 7:17 pm Post subject: RGB to HEX |
|
|
But how can I divide a value in 3 numbers? bacause if I take it out of the registry (%%BackgroundColor = @REGREAD(CURUSER,Control Panel\Colors,Background) I get 0 78 152. Is it possible to divide that into 3 numbers?
Erik |
|
| Back to top |
|
 |
Protected Valued Contributor


Joined: 02 Jan 2001 Posts: 228 Location: Portugal
|
Posted: Fri Aug 16, 2002 7:23 pm Post subject: |
|
|
Use the PARSE command. If your 0 78 152 is in %%NUMBER, it would look like:
OPTION FIELDSEP," "
PARSE "%A;%B;%C",%%NUMBER |
|
| Back to top |
|
 |
moke Contributor

Joined: 02 Jan 2002 Posts: 162
|
Posted: Fri Aug 16, 2002 7:24 pm Post subject: |
|
|
| Could you parse it using @chr(32) as the field sep? |
|
| Back to top |
|
 |
Tsunami1988 Contributor


Joined: 15 Aug 2002 Posts: 70 Location: The Netherlands
|
Posted: Fri Aug 16, 2002 7:25 pm Post subject: RGB -> HEX |
|
|
| OK, thnx. |
|
| Back to top |
|
 |
Tsunami1988 Contributor


Joined: 15 Aug 2002 Posts: 70 Location: The Netherlands
|
Posted: Fri Aug 16, 2002 7:44 pm Post subject: RGB to HEX |
|
|
another question:
Can I set a style to a color with DIALOG SET,STYLE1,BLACK ? (I downloaded a color picker a while ago, but I can't find it anymore)
Erik |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Aug 16, 2002 10:09 pm Post subject: |
|
|
No.
Styles are not treated like other elements in VDS. You must
add all styles you expect to use when you create the dialog.
BTW, here's a VDS Color Picker for HTML compatible colors:
http://www.vdsworld.com/forum/viewtopic.php?t=384
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 |
|
 |
Tsunami1988 Contributor


Joined: 15 Aug 2002 Posts: 70 Location: The Netherlands
|
Posted: Sat Aug 17, 2002 8:56 am Post subject: RGB -> HEX |
|
|
| OK, thanks again. |
|
| Back to top |
|
 |
|