POV-Ray : Newsgroups : povray.general : Colors of the rainbow : Re: Colors of the rainbow Server Time
30 Jul 2024 00:18:53 EDT (-0400)
  Re: Colors of the rainbow  
From: Alain
Date: 13 Apr 2010 11:07:19
Message: <4bc488a7$1@news.povray.org>

> Ah, so Hue varies from 0 to 360 degrees while Saturation and Value vary from 0
> to 1. That's a very interesting piece of information. Exactly what I needed to
> hear, Alain, merci!
>
> It worked perfectly.
>
> Ruy
>
> Alain<aze### [at] qwertyorg>  wrote:
>>
>> Change your code to:
>> #local Hue = (Mx-Cr)/Mx*360;
>> // Scale to a full circle on the colour wheel
>> // Adjust if you want to use a smaller or larger range
>> texture {
>>            pigment{rgb CHSV2RGB(<Hue, 1.0, 1.0>)}
>>           }
>>
>> OR change your pigment to:
>> pigment{rgb CHSV2RGB(<((Mx-Cr)/Mx)*360, 1.0, 1.0>)}
>>
>>
>>
>> Alain
>
>
>
>

To find that, you need to look inside colors.inc.
CHSV2RGB internaly calls CH2RGB.

CH2RGB is defined as:
#macro CH2RGB (H)
    #local H = mod(H, 360);
    #local H = (H < 0 ? H+360 : H);
    #switch (H)
       #range (0, 120)
          #local R = (120-  H) / 60;
          #local G = (  H-  0) / 60;
          #local B = 0;
       #break
       #range (120, 240)
          #local R = 0;
          #local G = (240-  H) / 60;
          #local B = (  H-120) / 60;
       #break
       #range (240, 360)
          #local R = (  H-240) / 60;
          #local G = 0;
          #local B = (360-  H) / 60;
       #break
    #end
    <min(R,1), min(G,1), min(B,1)>
#end

When you look at that code, it becomes obvious that you are using 
degrees. CHSL2RGB() also use degrees.
It should be added to the documentation.


Alain


Post a reply to this message

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