chroma_solstice/color.lua
2026-08-07 20:56:55 -04:00

31 lines
706 B
Lua

-- this module provides some helpful functions
-- for setting color!!
Color = class("Color")
Color.static.list = {
-- LÖVE 11 represents color components as normalized floats, not bytes.
red = {r = 1, g = 0, b = 0, a = 1},
green = {r = 0, g = 1, b = 0, a = 1},
blue = {r = 0, g = 0, b = 1, a = 1},
white = {r = 1, g = 1, b = 1, a = 1}
}
function Color:initialize(inColor)
self.name = inColor
local c = Color.list[inColor]
self.r, self.g, self.b, self.a = c.r, c.g, c.b, c.a
end
function Color:set()
return self.r, self.g, self.b, self.a
end
function Color:getname()
return self.name
end
function randomColor()
local colors = {"red", "green", "blue"}
return colors[math.random(1, 3)]
end