-
-
Save dvdfu/b0b4f9680eccd0276108ac9a18ce9365 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
local RGBColor = {} | |
local function lerp(a, b, x) | |
if x > 1 then x = 1 end | |
if x < 0 then x = 0 end | |
return a + (b-a) * x | |
end | |
function RGBColor.new(r, g, b) | |
return { | |
r = r, | |
g = g, | |
b = b | |
} | |
end | |
function RGBColor.blend(colorA, colorB, mix) | |
return { | |
r = lerp(colorA.r, colorB.r, mix), | |
g = lerp(colorA.g, colorB.g, mix), | |
b = lerp(colorA.b, colorB.b, mix) | |
} | |
end | |
function RGBColor.get(color) | |
return color.r, color.g, color.b | |
end | |
return RGBColor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment