Off-screen drawing surface for compositing and overlays
Sprites are off-screen RGB565 buffers allocated in PSRAM. Create with ez.display.create_sprite(w,h), draw to them using the same primitives as the display, then push() to composite onto the screen with optional alpha. Useful for UI overlays, menus, and cached graphics. Call destroy() when done.
| Parameter | Description |
|---|---|
| color | Fill color (optional, defaults to black) |
sprite:clear(0x0000) -- Clear to black
sprite:clear(0xF81F) -- Clear to magenta(for transparency)
local sprite = ez.display.create_sprite(100, 100)
-- ... use sprite ...
sprite:destroy() -- Free memory immediately
| Parameter | Description |
|---|---|
| x | Center X |
| y | Center Y |
| r | Radius |
| color | Circle color |
sprite:draw_circle(50, 50, 20, colors.CYAN)
| Parameter | Description |
|---|---|
| x1 | Start X |
| y1 | Start Y |
| x2 | End X |
| y2 | End Y |
| color | Line color |
sprite:draw_line(0, 0, 50, 50, colors.YELLOW)
| Parameter | Description |
|---|---|
| x | X position relative to sprite |
| y | Y position relative to sprite |
| w | Width in pixels |
| h | Height in pixels |
| color | Outline color |
sprite:draw_rect(5, 5, 90, 40, colors.WHITE)
| Parameter | Description |
|---|---|
| x | X position |
| y | Y position |
| w | Width |
| h | Height |
| r | Corner radius |
| color | Outline color |
sprite:draw_round_rect(10, 10, 80, 30, 5, colors.WHITE)
| Parameter | Description |
|---|---|
| x | X position |
| y | Y position |
| text | Text string to draw |
| color | Text color |
sprite:draw_text(10, 10, "Overlay", colors.WHITE)
| Parameter | Description |
|---|---|
| x | Center X |
| y | Center Y |
| r | Radius |
| color | Fill color |
sprite:fill_circle(50, 50, 15, colors.RED)
| Parameter | Description |
|---|---|
| x | X position relative to sprite |
| y | Y position relative to sprite |
| w | Width in pixels |
| h | Height in pixels |
| color | Fill color |
sprite:fill_rect(0, 0, 100, 50, colors.BLUE)
| Parameter | Description |
|---|---|
| x | X position |
| y | Y position |
| w | Width |
| h | Height |
| r | Corner radius |
| color | Fill color |
sprite:fill_round_rect(10, 10, 80, 30, 5, colors.GREEN)
local h = sprite:height() -- Get sprite dimensions
| Parameter | Description |
|---|---|
| x | X position on screen |
| y | Y position on screen |
| alpha | Opacity 0-255 (optional, default 255 = opaque) |
sprite:push(100, 50) -- Fully opaque
sprite:push(100, 50, 128) -- 50% transparent
| Parameter | Description |
|---|---|
| color | RGB565 color to treat as transparent |
sprite:set_transparent_color(0xF81F) -- Magenta = transparent
local w = sprite:width() -- Get sprite dimensions