Generating colour mixer

Hi,

I would like to create a colour mixer like http://trycolors.com, but when i mix basic colours its not giving me proper out (eg) mixing yellow and blue in same proportion, it not giving green.

Please suggest a solution to sort this out.

Thanks in advance,
Ben

Your pice of code makes not much sense.

First of all (like Eric told you over here) you should differenciate between the two different color mixing systems. A PC monitor / TV / … uses additive colormixing. The mixing of light / frequencies. The 3 primary colors in the additive system are red, blue and green. The base color is black (no light at all)

The subtractive system applies when you mix real life paint. It’s primary colors are cyan, magenta and yellow. The base color is white. Real white light contains all colors / frequencies. When light hits a surface and is reflected by the surface, subtractive color mixing is happening as the surface might not reflecting all frequencies but may absorb some (subtracting the color from the reflected light) which results in the seen color.

When it comes to subtractive colors / mixing you have to further differenciate between the ideal / theoritical case and the real world. In the ideal case, mixing the 3 primary colors (cyan, magenta and yellow) will result in the color “black” (as all light will be absorbed by a surface with this color). However in the real world it’s not possible to mix pigments to get a “perfect absorber”. Mixing C+M+Y in the real world does yield some muddy gray as the resulting color can’t absorb all light.

The online color mixer you’ve linked does calculate the mixing of real world paint (and therefore uses the subtractive system). It’s fairly difficult and complex to imitate real world color mixing on a PC. If you want to do that you should read (a lot) about the subtractive system, (real world) paint and how to convert colors between the subtractive (CMYK) and the additive (RGB) system.