Can you mix 3 colours together?

I am making a blender and I need the drink colour to be the 3 colours mixed together. I know that you can mix 2 colours using

(Colour1):lerp(Colour2,0.5)

But is there a way you can mix 3 colours?

Mixing Colors

or

local function MixColors(Color1, Color2, Color3)
     local r = (Color1.R + Color2.R + Color3.R)/3
     local g = (Color1.G + Color2.G + Color3.G)/3
     local b = (Color1.B + Color2.B + Color3.B)/3
     return Color3.new(r,g,b)
end


code from the same post

1 Like

Mathemetically:

local color1
local color2
local color3

local r = (color1.R + color2.R + color3.R) / 3
local g = (color1.G + color2.G + color3.G) / 3
local b = (color1.B + color2.B + color3.B) / 3
local newColor = Color3.new(r, g, b)
1 Like

Oops, I forgot to take that in consideration, since it’s 3 numbers not two

Also note that this code won’t work as the values returned from .R, .G, and .B respectively are values 0 to 1, so you should use Color3.new(r, g, b) instead of Color3.fromRGB(r, g, b), as fromRGB expects numbers 0-255.

Here’s a version that works for any number of colors:

Keep in mind that this way of mixing colors will mostly just give you ugly grey colors.

3 Likes