Color Wheel

This macro was originally published in the POV-Ray user forum  in August 2011 and is a simple modification of the macro included in “colors.inc” to switch from RGB to HSV. This macro returns the pigment located at ”A” degrees of the input pigment into the color wheel. It is valid to calculate complementary colors. triads of color, etc …

Download (right button and “Save target as”): CW_angle.mcr

/*
Takes a pigment as input and returns the pigment placed
at A degrees in the cromatic wheel
pigment {CW_angle(Red,180} // returns cyan
pigment {CW_angle(Red,120} // returns green
pigment {CW_angle(Red,240} // returns blue
*/
 #macro CW_angle (COLOR,A)
   #local RGBFT = color COLOR;
   #local R = (RGBFT.red);
   #local G = (RGBFT.green);
   #local B = (RGBFT.blue);
   #local Min = min(R,min(G,B));
   #local Max = max(R,max(G,B));
   #local Span = Max-Min;
   #local H = CRGB2H (<R,G,B>, Max, Span);
   #local S = 0; #if (Max!=0) #local S = Span/Max; #end

   #local P = <H+A,S,Max,(RGBFT.filter),(RGBFT.transmit)> ;

   #local HSVFT = color P ;
#local H = (HSVFT.red);
   #local S = (HSVFT.green);
   #local V = (HSVFT.blue);
   #local SatRGB = CH2RGB(H);
   #local RGB = ( ((1-S)*<1,1,1> + S*SatRGB) * V );
   rgb <RGB.red,RGB.green,RGB.blue,(HSVFT.filter),
       (HSVFT.transmit)>
#end

 

Recommended links:

pd. Thanks to user Alain for its help in news.povray.org

 

 
This entry was posted in Macros and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>