CHGame 0.3.0
Libraries for the CHGame handheld
Loading...
Searching...
No Matches

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].
 

Detailed Description

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.

Function Documentation

◆ gfx_roundRect()

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.

Parameters
xLeft edge.
yTop edge.
wWidth; 0 or less draws nothing.
hHeight; 0 or less draws nothing.
rCorner radius in pixels.
cPalette index.

◆ gfx_fillRoundRect()

void gfx_fillRoundRect ( int  x,
int  y,
int  w,
int  h,
int  r,
uint8_t  c 
)

Fills a rounded rectangle (corners as gfx_roundRect()).

Parameters
xLeft edge.
yTop edge.
wWidth; 0 or less draws nothing.
hHeight; 0 or less draws nothing.
rCorner radius in pixels.
cPalette index.

◆ gfx_ellipse()

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.

Parameters
cxCentre column.
cyCentre row.
rxHorizontal radius in pixels.
ryVertical radius in pixels.
cPalette index.

◆ gfx_fillEllipse()

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).

Parameters
cxCentre column.
cyCentre row.
rxHorizontal radius in pixels.
ryVertical radius in pixels.
cPalette index.

◆ gfx_dither()

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.

Parameters
xLeft edge.
yTop edge.
wWidth.
hHeight.
cPalette index.
phase0 paints pixels where x + y is even, 1 where it is odd.

◆ gfx_remapRect()

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.

Parameters
xLeft edge.
yTop edge.
wWidth.
hHeight.
remap16 palette indices: the new colour for each old one.