DayDun
DayDun

Reputation: 59

How to blend two colors a specific amount

so how would you blend two colors?

Like you input color1, color2 and amount, so if amount is 0, it's 100% color1 and if amount is 1 it's 100% color2. Anything between is a mix of both.

How would you do that?

Upvotes: 1

Views: 154

Answers (1)

Kevin
Kevin

Reputation: 76254

Linear interpolation.

new_color_r = color1_r * (1 - amount) + color2_r * amount
new_color_g = color1_g * (1 - amount) + color2_g * amount
new_color_b = color1_b * (1 - amount) + color2_b * amount

Upvotes: 2

Related Questions