# How to Mix Colors

How can I mix 2 colors? Is this even possible?
Any ideas or help would be greatly appreciated.

Example:

``````local color_1 = Color3.fromRGB(86, 75, 60)
local color_2 = Color3.fromRGB(255, 255, 255)

local mixed_color = Color3.fromRGB(?, ?, ?)
``````
3 Likes

`Color3` has a lerp function, which essentially blends the two:

``````local color_1 = Color3.fromRGB(86, 75, 60)
local color_2 = Color3.fromRGB(255, 255, 255)

local mixed_color = color_1:Lerp(color_2, 0.5)
``````

Alternatively, you could get the mean of the colors:

``````local function CombineColors(...: Color3)
local length = select("#", ...)
local rV = 0
local gV = 0
local bV = 0

for index = 1, length do
local Color = select(index, ...)

rV += Color.R
gV += Color.G
bV += Color.B
end

return Color3.fromRGB(
rV / length,
gV / length,
bV / length
)
end
``````
2 Likes

Thank you so much for providing 2 amazing answers.

However, I have a question.
What is “alpha” in the lerp function? Although I looked it up, I have difficult time understand it.

It’s the percent between the first and second colours provided. If you had white and black, an alpha of `0.5` (or 50%) would make exactly grey.

1 Like

It’s essentially a multiplier to the color values. Let’s say there are two color values: Color A, and Color B. An `alpha` of zero would be the base color (Color A). An `alpha` of one would be the target color (Color B). At the same time, an `alpha` of 0.5 would be the halfway point between Color A and Color B.

In certain terms, it’s the percent of how the base matches the target.

Ah, that makes perfect sense!
Thank you so much.

1 Like