Created
May 16, 2017 20:45
-
-
Save juanescalona/c23d970942b87e26f36f2a5cda4c2c0e to your computer and use it in GitHub Desktop.
Color Mixer Algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rgbaSum = function(c1, c2){ | |
var a = c1.a + c2.a*(1-c1.a); | |
return { | |
r: (c1.r * c1.a + c2.r * c2.a * (1 - c1.a)) / a, | |
g: (c1.g * c1.a + c2.g * c2.a * (1 - c1.a)) / a, | |
b: (c1.b * c1.a + c2.b * c2.a * (1 - c1.a)) / a, | |
a: a | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment