This plugin provides a table containing some often used colors.
Provided colors
- white
- black
- gray
- silver
- maroon
- red
- green
- lime
- olive
- yellow
- navy
- blue
- purple
- fuchsia
- teal
- aqua
Usage
The execution of require "color" creates a table, returns it and stores it in the global variable named color. This table contains the tables of the provided colors. They can be accessed by the name of the color. Each color table has the format {red, green, blue}, with each component being an integer from 0 to 255. These colors can be used everytime scrupp expects a color.
Example
scrupp.init("Color Test", 600, 357, 32, false)
-- load the color plugin and store it in a local variable
-- for faster access
local color = require "color"
-- alternative:
-- require "color"
-- this example uses the font plugin
require "font"
local font = Font("fonts/Vera.ttf", 20)
-- generate a rectangle
local rect = {
100, 0, -- placeholder for the coordinates
0, 0,
495, 0,
495, 18,
0, 18,
relative = true,
fill = true
}
-- y-position of the displayed color
local y
main = {
render = function(dt)
y = 5
-- cycle through all available colors
for name, color in pairs(color) do
-- print the name of the color
font:print(10, y, name)
-- change the color of the rectangle
rect.color = color
-- change the y-coordinate of the rectangle
rect[2] = y
-- draw the colored rectangle
scrupp.draw(rect)
y = y + 22
end
end
}