- Home /
Mixing Colors Using Fractions
I am trying to create a color mixer that mixes multiple colors together, meaning 2 or more. I'd like the end result to look something like trycolors.com where you can choose how much of a certain color you'd like to put in. For example, let's mix a color that is one part yellow, three parts red, and four parts blue. This would make the resultant color a mix of 12% yellow, 38% red, and 50% blue. How would I go about doing this? I know I probably need to use the Color.Lerp() method, but how would I implement different colors and different divisions?
This seems simpler if the mixer prompts for x parts of the standard primary colors Red, Green, Blue. With the example you provided of a percentage, you could scale that percentage to the 0-255 weight for each RGB then build the color.
Answer by Eric5h5 · Dec 07, 2016 at 07:34 AM
For example, let's mix a color that is one part yellow, three parts red, and four parts blue.
var color = (Color.yellow*1 + Color.red*3 + Color.blue*4) / 8;
Your answer
Follow this Question
Related Questions
Material doesn't have a color property '_Color' 4 Answers
Changing two different objects renderer colour 1 Answer
Problem with coloring mesh with shaders properly 1 Answer
convert rgb to cmyk 1 Answer
Color.Lerp doesn't work 1 Answer