Drawing#
Declared in ui.h. See drawing for examples and the rules for palettes.
ui_draw_fn#
typedef void (*ui_draw_fn)(ui_rect_t area, void *context);
A canvas draw function. area is the canvas rectangle in screen coordinates and context the pointer passed to
ui_canvas. It runs while CEUI redraws the screen, with graphx drawing to the back buffer and the clip region set to
the visible part of the canvas. It may use any graphx call, may run more than once per frame, and must draw the same
picture each time.
ui_image#
void ui_image(const gfx_sprite_t *sprite, uint8_t scale);
Places a graphx sprite, sprite->width * scale by sprite->height * scale pixels. Transparent pixels are not
skipped. The sprite is not copied; it must stay valid after the frame, and changing its pixels does not redraw it
(draw a changing sprite in a canvas instead). Sprites are not dimmed under a modal.
Parameter |
Meaning |
|---|---|
|
A graphx sprite |
|
Integer scale, 1 or more. 0 counts as 1 |
ui_canvas#
void ui_canvas(int h, ui_draw_fn draw, void *context, unsigned version);
Reserves a rectangle as wide as the current column and h pixels high, and has draw paint it. The canvas is
redrawn as a whole when version changes, when it moves or changes size, or when something over it changed. It is
not dimmed under a modal.
Parameter |
Meaning |
|---|---|
|
Height in pixels |
|
The draw function |
|
Passed to |
|
Change it whenever the picture changes |
Use ui_color(slot) for theme colors inside draw. When the canvas is fully visible, draw lines with
gfx_Line_NoClip, because graphx’s clipped gfx_Line drops parts of steep lines.