Skip to main content

LCDElement


Editor typing

When editing code for a LCDElement, the Grid editor automatically types self, element, and ele as LCDElement - so you can call these functions directly:

self:draw_pixel() -- on the current element
element[1]:draw_pixel() -- on a specific element from the array

LCDElement:draw_swap


Updates the screen with the contents of the background buffer.

LCDElement:draw_swap()

LCDElement:draw_pixel


Draws a pixel at (x, y) with the specified color.

LCDElement:draw_pixel(
x: integer,
y: integer,
color: integer[]
)
@param x — X coordinate
@param y — Y coordinate
@param color — RGB color as {r, g, b} with 8-bit channels (0–255)

LCDElement:draw_line


Draws a line between two points.

LCDElement:draw_line(
x1: integer,
y1: integer,
x2: integer,
y2: integer,
color: integer[]
)
@param x1 — Start X coordinate
@param y1 — Start Y coordinate
@param x2 — End X coordinate
@param y2 — End Y coordinate
@param color — RGB color as {r, g, b} with 8-bit channels (0–255)

LCDElement:draw_rectangle


Draws a rectangle outline between two corner points.

LCDElement:draw_rectangle(
x1: integer,
y1: integer,
x2: integer,
y2: integer,
color: integer[]
)
@param x1 — Top-left X coordinate
@param y1 — Top-left Y coordinate
@param x2 — Bottom-right X coordinate
@param y2 — Bottom-right Y coordinate
@param color — RGB color as {r, g, b} with 8-bit channels (0–255)

LCDElement:draw_rectangle_filled


Draws a filled rectangle between two corner points.

LCDElement:draw_rectangle_filled(
x1: integer,
y1: integer,
x2: integer,
y2: integer,
color: integer[]
)
@param x1 — Top-left X coordinate
@param y1 — Top-left Y coordinate
@param x2 — Bottom-right X coordinate
@param y2 — Bottom-right Y coordinate
@param color — RGB color as {r, g, b} with 8-bit channels (0–255)

LCDElement:draw_rectangle_rounded


Draws a rounded rectangle outline between two corner points.

LCDElement:draw_rectangle_rounded(
x1: integer,
y1: integer,
x2: integer,
y2: integer,
radius: integer,
color: integer[]
)
@param x1 — Top-left X coordinate
@param y1 — Top-left Y coordinate
@param x2 — Bottom-right X coordinate
@param y2 — Bottom-right Y coordinate
@param radius — Corner radius in pixels
@param color — RGB color as {r, g, b} with 8-bit channels (0–255)

LCDElement:draw_rectangle_rounded_filled


Draws a filled rounded rectangle between two corner points.

LCDElement:draw_rectangle_rounded_filled(
x1: integer,
y1: integer,
x2: integer,
y2: integer,
radius: integer,
color: integer[]
)
@param x1 — Top-left X coordinate
@param y1 — Top-left Y coordinate
@param x2 — Bottom-right X coordinate
@param y2 — Bottom-right Y coordinate
@param radius — Corner radius in pixels
@param color — RGB color as {r, g, b} with 8-bit channels (0–255)

LCDElement:draw_polygon


Draws a polygon outline using coordinate arrays.

LCDElement:draw_polygon(
xs: integer[],
ys: integer[],
color: integer[]
)
@param xs — Array of X coordinates {x1, x2, x3, ...}
@param ys — Array of Y coordinates {y1, y2, y3, ...}
@param color — RGB color as {r, g, b} with 8-bit channels (0–255)

LCDElement:draw_polygon_filled


Draws a filled polygon using coordinate arrays.

LCDElement:draw_polygon_filled(
xs: integer[],
ys: integer[],
color: integer[]
)
@param xs — Array of X coordinates {x1, x2, x3, ...}
@param ys — Array of Y coordinates {y1, y2, y3, ...}
@param color — RGB color as {r, g, b} with 8-bit channels (0–255)

LCDElement:draw_text


Draws text at the specified position.

LCDElement:draw_text(
text: string,
x: integer,
y: integer,
size: integer,
color: integer[]
)
@param text — Text to draw
@param x — X coordinate
@param y — Y coordinate
@param size — Font size
@param color — RGB color as {r, g, b} with 8-bit channels (0–255)

LCDElement:draw_text_fast


Draws text at the specified position using fast rendering.

LCDElement:draw_text_fast(
text: string,
x: integer,
y: integer,
size: integer,
color: integer[]
)
@param text — Text to draw
@param x — X coordinate
@param y — Y coordinate
@param size — Font size
@param color — RGB color as {r, g, b} with 8-bit channels (0–255)

LCDElement:draw_area_filled


Fills an area with a solid color (no alpha blending).

LCDElement:draw_area_filled(
x1: integer,
y1: integer,
x2: integer,
y2: integer,
color: integer[]
)
@param x1 — Top-left X coordinate
@param y1 — Top-left Y coordinate
@param x2 — Bottom-right X coordinate
@param y2 — Bottom-right Y coordinate
@param color — RGB color as {r, g, b} with 8-bit channels (0–255)

LCDElement:draw_demo


Draws the n-th iteration of a built-in demo animation.

LCDElement:draw_demo(n: integer)
@param n — Demo iteration number

LCDElement:get_render_time


Returns the time spent rendering between the last two swaps, in microseconds.

LCDElement:get_render_time(): integer
@return microseconds — Render time

LCDElement:screen_index


Returns the screen index used by low-level global GUI APIs.

LCDElement:screen_index(): integer
@return screen_index — Screen index for use with gui_draw_* functions

LCDElement:screen_width


Returns the screen width in pixels.

LCDElement:screen_width(): integer
@return width — Screen width

LCDElement:screen_height


Returns the screen height in pixels.

LCDElement:screen_height(): integer
@return height — Screen height