dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 02 2005 at 22:38 | IP Logged
|
|
|
Yep, sure is...use the ph_htmlcolor function. This function takes a PowerHome RGB color and converts it to a string in the form #XXXXXX.
A PowerHome RGB color is merely the following formula:
Red + (256 * Green) + (65536 * Blue)
where each of the colors is a value from 0 to 255. Once you have an RGB value, you can use math to extract it like so:
int(rgb / 65536)
gives you the blue component.
int((rgb - int(rgb / 65536) * 65536) / 256)
gives you the green component.
rgb - int( rgb / 65536) * 65536 - int((rgb - int(rgb / 65536) * 65536) / 256) * 256
gives you the red component.
That last one gets a little long and messy. The above formulas are based solely upon standard math. We can also get the values by using bitwise ANDing as demonstrated in the formulas below:
ph_and(rgb,16711680) / 65536
gives you the blue
ph_and(rgb,65280) / 256
gives you the green
ph_and(rgb,255)
gives you the red.
Hope this helps,
Dave.
|