Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the math behind the Colour Wheel

I want to create a pie with 12 slices, with each slice a different colour.

Pretty much every colour wheel seems to follow the same format; eg: http://www.tigercolor.com/color-lab/color-theory/color-theory-intro.htm .

But what algorithms are there for generating the colours? What is the math behind RGB(theta)? Surely there must be some established science on this, but Google is not giving me any clues.

like image 749
P i Avatar asked Nov 20 '10 21:11

P i


People also ask

What is the theory behind the color wheel?

The color wheel is the basis of color theory, because it shows the relationship between colors. Colors that look good together are called a color harmony. Artists and designers use these to create a particular look or feel. You can use a color wheel to find color harmonies by using the rules of color combinations.

Is there math in color theory?

To perform color theory, all we need to do is add or subtract hue values to obtain complementary colors. No trigonometry required. You don't even have to touch the saturation or lightness values. The process is breathtakingly simple.

How is Colour value calculated?

Each level is measured by the range of decimal numbers from 0 to 255 (256 levels for each color). For example, if a color has zero Blue, it will be a mixture of Red and Green. This means we can generate 256 x 256 x 256 = 16.777.

What is the math term for color?

In fact, the color blue is associated with math because it is a cool technical color devoid of emotion and represents the kind of technical subject that is based mostly on facts and logic.


1 Answers

Have a look at http://www.easyrgb.com it has the algorithms behind many color conversions. Here's the RGB -> HSV one.

var_R = ( R / 255 )                     //RGB from 0 to 255
var_G = ( G / 255 )
var_B = ( B / 255 )

var_Min = min( var_R, var_G, var_B )    //Min. value of RGB
var_Max = max( var_R, var_G, var_B )    //Max. value of RGB
del_Max = var_Max - var_Min             //Delta RGB value 

V = var_Max

if ( del_Max == 0 )                     //This is a gray, no chroma...
{
   H = 0                                //HSV results from 0 to 1
   S = 0
}
else                                    //Chromatic data...
{
   S = del_Max / var_Max

   del_R = ( ( ( var_Max - var_R ) / 6 ) + ( del_Max / 2 ) ) / del_Max
   del_G = ( ( ( var_Max - var_G ) / 6 ) + ( del_Max / 2 ) ) / del_Max
   del_B = ( ( ( var_Max - var_B ) / 6 ) + ( del_Max / 2 ) ) / del_Max

   if      ( var_R == var_Max ) H = del_B - del_G
   else if ( var_G == var_Max ) H = ( 1 / 3 ) + del_R - del_B
   else if ( var_B == var_Max ) H = ( 2 / 3 ) + del_G - del_R

   if ( H < 0 ) H += 1
   if ( H > 1 ) H -= 1
}
like image 65
dalton Avatar answered Sep 30 '22 20:09

dalton