![]() |
CHGame 0.3.0
Libraries for the CHGame handheld
|
Rounded rectangles, ellipses, dithered fills and in-place recolouring. More...
Functions | |
| void | gfx_roundRect (int x, int y, int w, int h, int r, uint8_t c) |
| Draws a rounded rectangle's 1-pixel outline. | |
| void | gfx_fillRoundRect (int x, int y, int w, int h, int r, uint8_t c) |
| Fills a rounded rectangle (corners as gfx_roundRect()). | |
| void | gfx_ellipse (int cx, int cy, int rx, int ry, uint8_t c) |
| Draws an axis-aligned ellipse's 1-pixel outline, 2*rx+1 by 2*ry+1 pixels, centred on (cx, cy). | |
| void | gfx_fillEllipse (int cx, int cy, int rx, int ry, uint8_t c) |
| Draws a filled axis-aligned ellipse, 2*rx+1 by 2*ry+1 pixels, centred on (cx, cy). | |
| void | gfx_dither (int x, int y, int w, int h, uint8_t c, uint8_t phase) |
| Paints a 50% checkerboard of one colour over a rectangle, leaving the pixels in between alone. | |
| void | gfx_remapRect (int x, int y, int w, int h, const uint8_t *remap) |
| Recolours a rectangle in place through a 16-entry table: pixel = remap[pixel]. | |
Rounded rectangles, ellipses, dithered fills and in-place recolouring.
Clipped like everything in Drawing. Nothing here costs a sketch that does not call it: the linker drops what is unused.
| void gfx_roundRect | ( | int | x, |
| int | y, | ||
| int | w, | ||
| int | h, | ||
| int | r, | ||
| uint8_t | c | ||
| ) |
Draws a rounded rectangle's 1-pixel outline.
Corners are pixel-art arcs, not chamfers; r is clamped to half the shorter side, and r = 0 is a plain rectangle.
| x | Left edge. |
| y | Top edge. |
| w | Width; 0 or less draws nothing. |
| h | Height; 0 or less draws nothing. |
| r | Corner radius in pixels. |
| c | Palette index. |
| void gfx_fillRoundRect | ( | int | x, |
| int | y, | ||
| int | w, | ||
| int | h, | ||
| int | r, | ||
| uint8_t | c | ||
| ) |
Fills a rounded rectangle (corners as gfx_roundRect()).
| x | Left edge. |
| y | Top edge. |
| w | Width; 0 or less draws nothing. |
| h | Height; 0 or less draws nothing. |
| r | Corner radius in pixels. |
| c | Palette index. |
| void gfx_ellipse | ( | int | cx, |
| int | cy, | ||
| int | rx, | ||
| int | ry, | ||
| uint8_t | c | ||
| ) |
Draws an axis-aligned ellipse's 1-pixel outline, 2*rx+1 by 2*ry+1 pixels, centred on (cx, cy).
Integer only, no square roots.
| cx | Centre column. |
| cy | Centre row. |
| rx | Horizontal radius in pixels. |
| ry | Vertical radius in pixels. |
| c | Palette index. |
| void gfx_fillEllipse | ( | int | cx, |
| int | cy, | ||
| int | rx, | ||
| int | ry, | ||
| uint8_t | c | ||
| ) |
Draws a filled axis-aligned ellipse, 2*rx+1 by 2*ry+1 pixels, centred on (cx, cy).
| cx | Centre column. |
| cy | Centre row. |
| rx | Horizontal radius in pixels. |
| ry | Vertical radius in pixels. |
| c | Palette index. |
| void gfx_dither | ( | int | x, |
| int | y, | ||
| int | w, | ||
| int | h, | ||
| uint8_t | c, | ||
| uint8_t | phase | ||
| ) |
Paints a 50% checkerboard of one colour over a rectangle, leaving the pixels in between alone.
Darkened backdrops behind menus, felt, shadows.
| x | Left edge. |
| y | Top edge. |
| w | Width. |
| h | Height. |
| c | Palette index. |
| phase | 0 paints pixels where x + y is even, 1 where it is odd. |
| void gfx_remapRect | ( | int | x, |
| int | y, | ||
| int | w, | ||
| int | h, | ||
| const uint8_t * | remap | ||
| ) |
Recolours a rectangle in place through a 16-entry table: pixel = remap[pixel].
Dimming, tinting, a hit flash on what is already drawn. A rectangle of 512 pixels or more builds a 256-entry table first and then costs one lookup per two pixels.
| x | Left edge. |
| y | Top edge. |
| w | Width. |
| h | Height. |
| remap | 16 palette indices: the new colour for each old one. |