The clip rectangle, pixels, lines, rectangles, circles and sprite blits, drawn into the 4 bpp framebuffer.
More...
|
| void | gfx_setClip (int x, int y, int w, int h) |
| | Sets the clip rectangle every drawing call stays inside.
|
| |
| void | gfx_resetClip (void) |
| | Puts the clip rectangle back to the whole screen.
|
| |
| void | gfx_getClip (int *x, int *y, int *w, int *h) |
| | Reads the clip rectangle, as intersected with the screen.
|
| |
| void | gfx_clear (uint8_t c) |
| | Fills the clip rectangle (normally the whole screen) with one colour.
|
| |
| void | gfx_pixel (int x, int y, uint8_t c) |
| | Sets one pixel.
|
| |
| uint8_t | gfx_getPixel (int x, int y) |
| | Reads one pixel of the framebuffer (the clip is ignored).
|
| |
| void | gfx_hline (int x, int y, int w, uint8_t c) |
| | Draws a horizontal line from (x, y), w pixels to the right.
|
| |
| void | gfx_vline (int x, int y, int h, uint8_t c) |
| | Draws a vertical line from (x, y), h pixels down.
|
| |
| void | gfx_fillRect (int x, int y, int w, int h, uint8_t c) |
| | Fills a rectangle.
|
| |
| void | gfx_rect (int x, int y, int w, int h, uint8_t c) |
| | Draws a rectangle's 1-pixel outline.
|
| |
| void | gfx_line (int x0, int y0, int x1, int y1, uint8_t c) |
| | Draws a line between two points, both ends included.
|
| |
| void | gfx_circle (int cx, int cy, int r, uint8_t c) |
| | Draws a circle's 1-pixel outline, 2*r+1 pixels across.
|
| |
| void | gfx_fillCircle (int cx, int cy, int r, uint8_t c) |
| | Draws a filled circle, 2*r+1 pixels across.
|
| |
| void | gfx_blit (const uint8_t *spr, int x, int y, int w, int h, int transparent) |
| | Copies a 4 bpp bitmap into the framebuffer, optionally with one colour transparent.
|
| |
|
| uint8_t | gfx_fb [GFX_FB_BYTES] |
| | The framebuffer: GFX_FB_BYTES of 4 bpp pixels, two per byte.
|
| |
The clip rectangle, pixels, lines, rectangles, circles and sprite blits, drawn into the 4 bpp framebuffer.
Every colour is a palette index, 0..15 (only the low 4 bits are used). Every call is clipped to the clip rectangle, and nothing reaches the panel until a flush. Draw only after gfx_wait() (or gfx_waitRow() for the rows you touch).
The clip rectangle. Every call that paints pixels - fills, lines, shapes, text, sprites, gfx_clear() - stays inside it. It is intersected with the screen; an empty one (w or h <= 0) stops all drawing. Defaults to the whole screen. gfx_getPixel(), gfx_scroll() and the flush ignore it. Changing it costs nothing, so set it around a panel or a HUD and put it back:
void gfx_setClip(int x, int y, int w, int h)
Sets the clip rectangle every drawing call stays inside.
void gfx_resetClip(void)
Puts the clip rectangle back to the whole screen.
◆ gfx_setClip()
| void gfx_setClip |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
w, |
|
|
int |
h |
|
) |
| |
Sets the clip rectangle every drawing call stays inside.
- Parameters
-
| x | Left edge, in pixels. |
| y | Top edge, in pixels. |
| w | Width; 0 or less stops all drawing. |
| h | Height; 0 or less stops all drawing. |
◆ gfx_resetClip()
| void gfx_resetClip |
( |
void |
| ) |
|
Puts the clip rectangle back to the whole screen.
◆ gfx_getClip()
| void gfx_getClip |
( |
int * |
x, |
|
|
int * |
y, |
|
|
int * |
w, |
|
|
int * |
h |
|
) |
| |
Reads the clip rectangle, as intersected with the screen.
- Parameters
-
| [out] | x | Left edge (may be nullptr). |
| [out] | y | Top edge (may be nullptr). |
| [out] | w | Width (may be nullptr). |
| [out] | h | Height (may be nullptr). |
◆ gfx_clear()
| void gfx_clear |
( |
uint8_t |
c | ) |
|
Fills the clip rectangle (normally the whole screen) with one colour.
The whole screen is one word store per 8 pixels, from SRAM.
- Parameters
-
◆ gfx_pixel()
| void gfx_pixel |
( |
int |
x, |
|
|
int |
y, |
|
|
uint8_t |
c |
|
) |
| |
Sets one pixel.
- Parameters
-
| x | Column. |
| y | Row. |
| c | Palette index. |
◆ gfx_getPixel()
| uint8_t gfx_getPixel |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
Reads one pixel of the framebuffer (the clip is ignored).
- Parameters
-
- Returns
- The palette index there, or 0 off the screen.
◆ gfx_hline()
| void gfx_hline |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
w, |
|
|
uint8_t |
c |
|
) |
| |
Draws a horizontal line from (x, y), w pixels to the right.
- Parameters
-
| x | Left end. |
| y | Row. |
| w | Length in pixels; 0 or less draws nothing. |
| c | Palette index. |
◆ gfx_vline()
| void gfx_vline |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
h, |
|
|
uint8_t |
c |
|
) |
| |
Draws a vertical line from (x, y), h pixels down.
- Parameters
-
| x | Column. |
| y | Top end. |
| h | Length in pixels; 0 or less draws nothing. |
| c | Palette index. |
◆ gfx_fillRect()
| void gfx_fillRect |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
w, |
|
|
int |
h, |
|
|
uint8_t |
c |
|
) |
| |
Fills a rectangle.
- Parameters
-
| x | Left edge. |
| y | Top edge. |
| w | Width; 0 or less draws nothing. |
| h | Height; 0 or less draws nothing. |
| c | Palette index. |
◆ gfx_rect()
| void gfx_rect |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
w, |
|
|
int |
h, |
|
|
uint8_t |
c |
|
) |
| |
Draws a rectangle's 1-pixel outline.
- Parameters
-
| x | Left edge. |
| y | Top edge. |
| w | Width; 0 or less draws nothing. |
| h | Height; 0 or less draws nothing. |
| c | Palette index. |
◆ gfx_line()
| void gfx_line |
( |
int |
x0, |
|
|
int |
y0, |
|
|
int |
x1, |
|
|
int |
y1, |
|
|
uint8_t |
c |
|
) |
| |
Draws a line between two points, both ends included.
- Parameters
-
| x0 | Start column. |
| y0 | Start row. |
| x1 | End column. |
| y1 | End row. |
| c | Palette index. |
◆ gfx_circle()
| void gfx_circle |
( |
int |
cx, |
|
|
int |
cy, |
|
|
int |
r, |
|
|
uint8_t |
c |
|
) |
| |
Draws a circle's 1-pixel outline, 2*r+1 pixels across.
- Parameters
-
| cx | Centre column. |
| cy | Centre row. |
| r | Radius in pixels. |
| c | Palette index. |
◆ gfx_fillCircle()
| void gfx_fillCircle |
( |
int |
cx, |
|
|
int |
cy, |
|
|
int |
r, |
|
|
uint8_t |
c |
|
) |
| |
Draws a filled circle, 2*r+1 pixels across.
- Parameters
-
| cx | Centre column. |
| cy | Centre row. |
| r | Radius in pixels. |
| c | Palette index. |
◆ gfx_blit()
| void gfx_blit |
( |
const uint8_t * |
spr, |
|
|
int |
x, |
|
|
int |
y, |
|
|
int |
w, |
|
|
int |
h, |
|
|
int |
transparent |
|
) |
| |
Copies a 4 bpp bitmap into the framebuffer, optionally with one colour transparent.
Source rows are packed the same way as the framebuffer (2 px/byte, even x low nibble), each row padded to a whole byte. The opaque even-x case runs at memcpy speed. For art with many runs of one colour, the compact span sprites are smaller.
- Parameters
-
| spr | The bitmap, (w + 1) / 2 bytes a row. |
| x | Left edge on screen. |
| y | Top edge on screen. |
| w | Width in pixels. |
| h | Height in pixels. |
| transparent | Colour index skipped, or -1 for an opaque copy. |
◆ gfx_fb
The framebuffer: GFX_FB_BYTES of 4 bpp pixels, two per byte.
Row y starts at gfx_fb + y * GFX_FB_STRIDE. Even x is in the LOW nibble, odd x in the HIGH nibble - that ordering makes the expansion LUT a single uint32 store with no shuffling on a little-endian core. Each nibble is a palette index. Write it directly only for primitives of your own, and only when no flush is reading it (after gfx_wait()).