2015-03-11 20:11:29 -04:00
|
|
|
-- this module provides some helpful functions
|
|
|
|
|
-- for setting color!!
|
|
|
|
|
|
|
|
|
|
Color = class("Color")
|
|
|
|
|
|
2015-03-12 03:04:09 -04:00
|
|
|
Color.static.list = {
|
2026-08-07 20:56:42 -04:00
|
|
|
-- 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}
|
2015-03-12 03:04:09 -04:00
|
|
|
}
|
|
|
|
|
|
2015-03-11 20:11:29 -04:00
|
|
|
function Color:initialize(inColor)
|
2015-03-17 01:59:14 -04:00
|
|
|
self.name = inColor
|
2015-03-12 03:04:09 -04:00
|
|
|
local c = Color.list[inColor]
|
|
|
|
|
self.r, self.g, self.b, self.a = c.r, c.g, c.b, c.a
|
2015-03-11 20:11:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Color:set()
|
|
|
|
|
return self.r, self.g, self.b, self.a
|
2015-03-12 03:04:09 -04:00
|
|
|
end
|
|
|
|
|
|
2015-03-17 01:59:14 -04:00
|
|
|
function Color:getname()
|
|
|
|
|
return self.name
|
|
|
|
|
end
|
|
|
|
|
|
2015-03-12 03:04:09 -04:00
|
|
|
function randomColor()
|
|
|
|
|
local colors = {"red", "green", "blue"}
|
|
|
|
|
return colors[math.random(1, 3)]
|
2026-08-07 20:56:42 -04:00
|
|
|
end
|