lcd.RGB¶
since 1.1.0
Get a color from red, green and blue values with optional alpha opacity.
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
red |
integer | yes | red value(0 - 255) |
green |
integer | yes | green value(0 - 255) |
blue |
integer | yes | blue value(0 - 255) |
alpha |
number | optional | alpha value(0 - 1.0) |
Returns¶
color (integer)
Examples¶
-- build colors once, at file level, and reuse them in paint()
local ORANGE = lcd.RGB(255, 128, 0)
local SHADOW = lcd.RGB(0, 0, 0, 0.4) -- 40 % opaque black
local WARNING = lcd.RGB(0xE6, 0x32, 0x32) -- hex components work too
local function paint(widget)
lcd.color(widget.alarm and WARNING or ORANGE)
lcd.drawFilledRectangle(0, 0, 20, 20)
end
Tip
lcd.RGB is one of the most-called functions in real scripts. Calling it with constant arguments inside paint repeats work every frame; compute constant colors once.
Used in¶
- Battery gauge widget
- Timer control
- Telemetry value widget
- theme
- tool-form
- widget-form
- widget-gauge
- widget-lcddemo
- widget-sinus
- xxxxl
Real-world usage¶
Called 637 times across 11 open-source Ethos Lua projects. A few short excerpts: