POV-Ray : Newsgroups : povray.newusers : Translate colors : Re: Translate colors Server Time
4 Nov 2024 21:23:26 EST (-0500)
  Re: Translate colors  
From: Ken
Date: 14 Aug 2001 09:48:21
Message: <3B792CAD.F833724B@pacbell.net>
Kari Kivisalo wrote:
> 
> Hershel Robinson wrote:
> 
> > How do I translate colors from HTML format, i.e. color="#D5EAFF" to POV
> > format?
> 
> #declare AG=1;
> #global_settings{assumed_gamma AG}
> 
> #macro G(Color)
>   #local DisplayGamma=2.2; // Display_Gamma from povray.ini
>   #local Gamma=DisplayGamma/AG;
>   <pow(Color.x,Gamma),pow(Color.y,Gamma),pow(Color.z,Gamma)>
> #end
> 
> #macro H2D(Hex)
>   #local H=strupr(Hex)
>   #local D1=asc(substr(H,1,1))-65;
>   #local D2=asc(substr(H,1,1))-65;
>   (D1<0 ? D1+17 : D1+10)*16 + (D2<0 ? D2+17 : D2+10)
> #end
> 
> #macro Hex2Color(C)
>   (<H2D(substr(C,1,2)),H2D(substr(C,3,2)),H2D(substr(C,5,2))>/255)
> #end
> 
> camera{location -3*z look_at 0}
> 
> box{-1,1
>  pigment{rgb G(Hex2Color("D5EAFF"))}
>  finish{diffuse 0 ambient 1}
> }

If that is your idea of a new user solution I would hate to see what you
provide for an advanced user :)

-- 
Ken Tyler


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.