Skip to content

lcd.drawRectangle

since 1.1.0

Draw a rectangle.

lcd.drawRectangle(x, y, w, h[, thickness])

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
thickness integer optional (default 1) the thickness of the rectangle frame

Returns

Nothing.

Examples

lcd.drawRectangle(10, 10, 100, 40)        -- 1 px outline
lcd.drawRectangle(10, 60, 100, 40, 3)     -- 3 px thick outline

-- highlight the focused element
if lcd.hasFocus() then
  lcd.color(lcd.themeColor(THEME_FOCUS_COLOR))
  lcd.drawRectangle(0, 0, w, h, 2)
end

Used in

Real-world usage

Called 116 times across 10 open-source Ethos Lua projects. A few short excerpts:
lcd.drawRectangle(sx - r, sy - r, r * 2, r * 2, 1)

src/ethos-arcade/games/luadefender/game.lua:1693

if border then lcd.drawRectangle(x - padX, y - padY, bestW + padX * 2, bestH + padY * 2) end

src/dashx/widgets/dashboard/lib/utils.lua:688

lcd.color(grid)
lcd.drawRectangle(infoX, infoY, infoW, infoH)

src/rfsuite/app/alignment_visual.lua:213