POV-Ray : Newsgroups : povray.general : How to autmatically change the color of balls? : Re: How to autmatically change the color of balls? Server Time
31 Jul 2024 22:15:23 EDT (-0400)
  Re: How to autmatically change the color of balls?  
From: Roman Reiner
Date: 28 Aug 2006 17:45:00
Message: <web.44f362bb94ddb2abf1fef7e90@news.povray.org>
If you're able to control the format of that file it would be easier to have
the syntax:

<x,y,z>,E

and read MyVect directly:

#while (defined(MyFile))
  #read (MyFile, MyVect)
  sphere {MyVect, 1 texture {pigment {color rgb <a,b,c>}}}
#end
#fclose MyFile

To answer your question, it is possible.
The easiest approach i'm aware of is declaring the color in HSL color space
(hue, saturation, lighness) and convert it to RGB color (red, green, blue)
with the function CHSL2RGB(Color) in "colors.inc"
(see documentation for details
http://www.povray.org/documentation/view/3.6.1/434/)

then something like

pigment { color rgb CHSL2RGB<E,240,120> }

where E is in the range 160 (blue) to 0 (red) should do.

It's possible that i'm confusing the range of the HSL values. i think its
<0,0,0> to <240,240,240> but i'm not sure. you might need some testing or
an advice of another person...

Hope that helps
Regards Roman


Post a reply to this message

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