Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/functions_content.php on line 661

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/functions_content.php on line 661

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/functions_content.php on line 661

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/functions_content.php on line 661

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/functions_content.php on line 661

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/functions_content.php on line 661

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/functions_content.php on line 661

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/functions_content.php on line 661

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/ubercode/public_html/forum/includes/bbcode.php on line 483
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3729: Cannot modify header information - headers already sent by (output started at /includes/functions_content.php:661)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3731: Cannot modify header information - headers already sent by (output started at /includes/functions_content.php:661)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3732: Cannot modify header information - headers already sent by (output started at /includes/functions_content.php:661)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3733: Cannot modify header information - headers already sent by (output started at /includes/functions_content.php:661)
ubercode.com • View topic - How to obtain RGB string from Color Dialog

How to obtain RGB string from Color Dialog

Make suggestions of things to add or change in Ubercode.

How to obtain RGB string from Color Dialog

Postby onykage on Fri Sep 10, 2010 5:19 am

ok,

when you call the coluorDialog() it returns a "hexadecimal" number right? So.. why does "hexstr()" return the hex color code backwards?

for example the color Gold would be represented by #9f9a2f, but hexstr will return 2f9a9f. what have a managed to do wrong here?

eg

var
color:integer(0:MAXINT)
code
call ColourDialog("title", 0, color)
call msgBox(hexstr(color))

what else is weird is if the last responded digit is a "nand", nothing is returned, ie Red which is ff0000 is returned as ff.

please tell me im not crazy here. :)
onykage
Admin
 
Posts: 221
Joined: Sat Jan 03, 2009 8:28 pm
Location: Armpit USA
Programming languages: php, java, python, ubercode, easyuo, peril, cobal, pascal, ruby

Re: color dialog

Postby ubercode on Tue Sep 14, 2010 4:48 pm

No you're not going crazy :)

They are different ways of viewing the same thing. When you specify a color in the color dialog or using RGB in Ubercode, the convention is R,G,B. So Red is RGB(255,0,0) or RGB(0xFF,0,0) in hex or #FF0000 using the web RGB codes (all 3 are the same).

When the color is stored in an integer value, the Intel processor stores R as the least significant byte, then G, then B. So 0x0000FF is red, 0x00FF00 is green and 0xFF0000 is blue. So if you call Hexstr on an RGB value, it always comes out 'back to front'.

It's probably easier to use RGB to build color values to avoid confusion, and don't look at the actual integer value.

Hope this helps!
ubercode
Site Owner
 
Posts: 275
Joined: Sun Jan 04, 2009 3:46 pm
Location: UK Channel Islands

Re: color dialog

Postby onykage on Tue Sep 14, 2010 8:35 pm

ok so how do you use the RGB?? it returns an integer. How do I convert the output directly or use it as such.

For example what I want to do is just translate the color from the color selection dialog to either an RGB value or a Hex value so i can pass it to a PDF for coloring.
onykage
Admin
 
Posts: 221
Joined: Sat Jan 03, 2009 8:28 pm
Location: Armpit USA
Programming languages: php, java, python, ubercode, easyuo, peril, cobal, pascal, ruby

Re: color dialog

Postby ubercode on Sat Sep 18, 2010 1:14 pm

I understand what you mean now - you want a string in the form RRGGBB for the color. Paste these 3 helper functions into the top of your class:

Code: Select all
public function GetRValue(in clr:integer out red:integer) // Gets Red
code
  red <- clr mod 256
end function

public function GetGValue(in clr:integer out green:integer) // Gets Green
code
  green <- (clr div 256) mod 256
end function

public function GetBValue(in clr:integer out blue:integer) // Gets Blue
code
  blue <- (clr div 65536) mod 256
end function


These get the revelant color from an integer. Then convert the value from the color dialog to the hex color string:

Code: Select all
myString <- Hexstr(GetRValue(rgbColor), +2, "0") +
            Hexstr(GetGValue(rgbColor), +2, "0") +
            Hexstr(GetBValue(rgbColor), +2, "0")


This should give you the RGB string needed by PDF files, HTML, CSS etc.
ubercode
Site Owner
 
Posts: 275
Joined: Sun Jan 04, 2009 3:46 pm
Location: UK Channel Islands

Re: How to obtain RGB string from Color Dialog

Postby ubercode on Sat Jan 15, 2011 11:04 pm

Moved to Language Suggestions forum
ubercode
Site Owner
 
Posts: 275
Joined: Sun Jan 04, 2009 3:46 pm
Location: UK Channel Islands


Return to Language Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest

cron