|
|
In article <web.4141045b864bcff549700cac0@news.povray.org>,
"Mike Thorn" <films!@!roboticsresources.com> wrote:
> Hi,
>
> Is there a simple way to convert a hex value into Pov's RGB system?
>
> I'm not sure what exactly to call Pov's vector system so I had difficulty
> researching this myself. If anyone can help me, I would appreciate it. I'm
> sure somebody out there is able. :)
>
> Thanks,
> ~Mike
>
>
hi,
try this :
// --- the macro -------------------------------------------------------------
#macro hex2rgb (hexString)
#macro hex2dec (theHexValue)
(asc(theHexValue)>64?asc(theHexValue)-55:asc(theHexValue)-48)
#end
<16*hex2dec(substr(hexString,1,1))+hex2dec(substr(hexString,2,1)),
16*hex2dec(substr(hexString,3,1))+hex2dec(substr(hexString,4,1)),
16*hex2dec(substr(hexString,5,1))+hex2dec(substr(hexString,6,1))>/255
#end
// --- sample ----------------------------------------------------------------
#declare HexColor = "36F0CF";
#declare PovColor = hex2rgb(HexColor);
#debug concat("\n Red = ",str(PovColor.red,7,6)," Green =
",str(PovColor.green,7,6)," Blue = ",str(PovColor.blue,7,6),"\n")
Post a reply to this message
|
|