Skip to content

lcd.drawFilledRectangle

since 1.1.0

Draw a filled rectangle.

lcd.drawFilledRectangle(x, y, w, h)

Parameters

Name Type Required Description
x number yes X coordinate
y number yes Y coordinate
w number yes rectangle width
h number yes rectangle height

Returns

Nothing.

Examples

-- a horizontal bar: track + fill
local TRACK, FILL = lcd.GREY(60), lcd.RGB(40, 190, 80)

local function drawBar(x, y, w, h, percent)
  lcd.color(TRACK)
  lcd.drawFilledRectangle(x, y, w, h)
  lcd.color(FILL)
  lcd.drawFilledRectangle(x, y, math.floor(w * percent / 100), h)
end

See the battery gauge recipe for a complete widget.

Used in

Real-world usage

Called 354 times across 12 open-source Ethos Lua projects. A few short excerpts:
lcd.drawFilledRectangle(x, y, w, h)

src/rfsuite/widgets/dashboard/objects/gauge/bar.lua:129

lcd.drawFilledRectangle(px, py, pw, ph)

src/ethos-arcade/games/luafrog/game.lua:1134

lcd.drawFilledRectangle(z_x, z_y, z_w, z_h)

src/dashx/app/modules/logs/logs_view.lua:415