Rgb
From codeTank
Contents |
Description
rgb creates tables that holds color information. It is primarily used to specify color for paint or image functions.
Arguments
rgb() -- equivalent to rgb(0, 0, 0) rgb(red) -- equivalent to rgb(red, 0, 0) rgb(red, green) -- equivalent to rgb(red, green, 0) rgb(red, green, blue)
There are three optional arguments for rgb. Each argument specifies an amount of intensity per color channel. The three color channels are red, green, and blue. Each channel can range from 0 (void of color), to 255 (maximum color).
Examples:
rgb(255, 0, 0) -- pure red rgb(0, 255, 0) -- pure green rgb(0, 0, 255) -- pure blue rgb(84, 84, 84) -- dark gray rgb(255, 140, 0) -- dark orange rgb(178, 34, 34) -- fire brick
Note: As added convenience, rgb can also accept a table instead of a list of arguments.
Returns
rgb will return a table, with the appropriate values set. rgb is equivalent to:
function rgb(r, g, b) r = tonumber(r) or 0 g = tonumber(g) or 0 b = tonumber(b) or 0 return {r, g, b, red = r, green = g, blue = b, r = r, g = g, b = b} end
Example
window_color = rgb(100, 200, 255) wnd = window.create{ onerasebkgnd = function(wnd, pnt) pnt:rectangle(0, 0, wnd.width, wnd.height, false, window_color) return false end, } while window.getcount() > 0 do window.pumpmessages() end

