Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
Macros | |
#define | TEXT_DRAW 0 |
Flag for drawTextWordWrapFlags() to draw the text normally. | |
#define | TEXT_MEASURE 1 |
Flag for drawTexTWordWrapFlags() to measure the text without drawing. | |
#define | MARQUEE_SPEED 40000 |
Functions | |
void | drawCharBounds (paletteColor_t color, int h, const font_ch_t *ch, int16_t xOff, int16_t yOff, int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax) |
Draw a single character from a font to a display. | |
void | drawChar (paletteColor_t color, int h, const font_ch_t *ch, int16_t xOff, int16_t yOff) |
Draw a single character from a font to a display. | |
int16_t | drawTextBounds (const font_t *font, paletteColor_t color, const char *text, int16_t xOff, int16_t yOff, int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax) |
Draw text to a display with the given color and font. | |
int16_t | drawText (const font_t *font, paletteColor_t color, const char *text, int16_t xOff, int16_t yOff) |
Draw text to a display with the given color and font. | |
uint16_t | textWidth (const font_t *font, const char *text) |
Return the pixel width of some text in a given font. | |
const char * | drawTextWordWrap (const font_t *font, paletteColor_t color, const char *text, int16_t *xOff, int16_t *yOff, int16_t xMax, int16_t yMax) |
Draws text, breaking on word boundaries, until the given bounds are filled or all text is drawn. | |
const char * | drawTextWordWrapFixed (const font_t *font, paletteColor_t color, const char *text, int16_t xStart, int16_t yStart, int16_t *xOff, int16_t *yOff, int16_t xMax, int16_t yMax) |
uint16_t | textWordWrapHeight (const font_t *font, const char *text, int16_t width, int16_t maxHeight) |
Return the height of a block of word wrapped text. | |
void | makeOutlineFont (font_t *srcFont, font_t *dstFont, bool spiRam) |
Create the outline of a font as a separate font. | |
int16_t | drawTextMarquee (const font_t *font, paletteColor_t color, const char *text, int16_t xOff, int16_t yOff, int16_t xMax, int32_t *timer) |
Draw text to the display with a marquee effect. | |
bool | drawTextEllipsize (const font_t *font, paletteColor_t color, const char *text, int16_t xOff, int16_t yOff, int16_t maxW, bool center) |
Draw text to the display that fits within a given length, replacing any overflowing text with "...". | |
int16_t | drawTextMulticolored (const font_t *font, const char *text, int16_t xOff, int16_t yOff, const paletteColor_t *colors, uint32_t colorCount, uint32_t segmentCount) |
Draws text divided into any number of colored segments. | |
#define TEXT_DRAW 0 |
Flag for drawTextWordWrapFlags() to draw the text normally.
#define TEXT_MEASURE 1 |
Flag for drawTexTWordWrapFlags() to measure the text without drawing.
#define MARQUEE_SPEED 40000 |
void drawCharBounds | ( | paletteColor_t | color, |
int | h, | ||
const font_ch_t * | ch, | ||
int16_t | xOff, | ||
int16_t | yOff, | ||
int16_t | xMin, | ||
int16_t | yMin, | ||
int16_t | xMax, | ||
int16_t | yMax ) |
Draw a single character from a font to a display.
color | The color of the character to draw |
h | The height of the character to draw |
ch | The character bitmap to draw (includes the width of the char) |
xOff | The x offset to draw the char at |
yOff | The y offset to draw the char at |
xMin | The left edge of the text bounds |
yMin | The top edge of the text bounds |
xMax | The right edge of the text bounds |
yMax | The bottom edge of the text bounds |
void drawChar | ( | paletteColor_t | color, |
int | h, | ||
const font_ch_t * | ch, | ||
int16_t | xOff, | ||
int16_t | yOff ) |
Draw a single character from a font to a display.
color | The color of the character to draw |
h | The height of the character to draw |
ch | The character bitmap to draw (includes the width of the char) |
xOff | The x offset to draw the char at |
yOff | The y offset to draw the char at |
int16_t drawTextBounds | ( | const font_t * | font, |
paletteColor_t | color, | ||
const char * | text, | ||
int16_t | xOff, | ||
int16_t | yOff, | ||
int16_t | xMin, | ||
int16_t | yMin, | ||
int16_t | xMax, | ||
int16_t | yMax ) |
Draw text to a display with the given color and font.
font | The font to use for the text |
color | The color of the character to draw |
text | The text to draw to the display |
xOff | The x offset to draw the text at |
yOff | The y offset to draw the text at |
xMin | The left edge of the text bounds |
yMin | The top edge of the text bounds |
xMax | The right edge of the text bounds |
yMax | The bottom edge of the text bounds |
int16_t drawText | ( | const font_t * | font, |
paletteColor_t | color, | ||
const char * | text, | ||
int16_t | xOff, | ||
int16_t | yOff ) |
Draw text to a display with the given color and font.
font | The font to use for the text |
color | The color of the character to draw |
text | The text to draw to the display |
xOff | The x offset to draw the text at |
yOff | The y offset to draw the text at |
uint16_t textWidth | ( | const font_t * | font, |
const char * | text ) |
Return the pixel width of some text in a given font.
font | The font to use |
text | The text to measure |
const char * drawTextWordWrap | ( | const font_t * | font, |
paletteColor_t | color, | ||
const char * | text, | ||
int16_t * | xOff, | ||
int16_t * | yOff, | ||
int16_t | xMax, | ||
int16_t | yMax ) |
Draws text, breaking on word boundaries, until the given bounds are filled or all text is drawn.
Text will be drawn, starting at (xOff, yOff)
, wrapping to the next line at ' ' or '-' when the next word would exceed xMax
, or immediately when a newline ('\n') is encountered. Carriage returns and tabs ('\r', '\t') are not supported. When the bottom of the next character would exceed yMax
, no more text is drawn and a pointer to the next undrawn character within text
is returned. If all text has been written, NULL is returned.
font | The font to use when drawing the text |
color | The color of the text to be drawn |
text | The text to be pointed, as a null-terminated string |
xOff | The X-coordinate to begin drawing the text at |
yOff | The Y-coordinate to begin drawing the text at |
xMax | The maximum x-coordinate at which any text may be drawn |
yMax | The maximum y-coordinate at which text may be drawn |
text
, or NULL if all text has been written const char * drawTextWordWrapFixed | ( | const font_t * | font, |
paletteColor_t | color, | ||
const char * | text, | ||
int16_t | xStart, | ||
int16_t | yStart, | ||
int16_t * | xOff, | ||
int16_t * | yOff, | ||
int16_t | xMax, | ||
int16_t | yMax ) |
uint16_t textWordWrapHeight | ( | const font_t * | font, |
const char * | text, | ||
int16_t | width, | ||
int16_t | maxHeight ) |
Return the height of a block of word wrapped text.
font | The font to use when drawing the text |
text | The text to be pointed, as a null-terminated string |
width | The maximum x-coordinate at which any text may be drawn |
maxHeight | The maximum y-coordinate at which text may be drawn |
Create the outline of a font as a separate font.
srcFont | The source font to make an outline of |
dstFont | The destination font that will be initialized as an outline of the source font |
spiRam | true to allocate memory in SPI RAM, false to allocate memory in normal RAM |
int16_t drawTextMarquee | ( | const font_t * | font, |
paletteColor_t | color, | ||
const char * | text, | ||
int16_t | xOff, | ||
int16_t | yOff, | ||
int16_t | xMax, | ||
int32_t * | timer ) |
Draw text to the display with a marquee effect.
font | The font to use for the text | |
color | The color of the character to draw | |
text | The text to draw to the display | |
xOff | The x offset to draw the text at | |
yOff | The y offset to draw the text at | |
xMax | The x offset of the right edge of the marquee text | |
[in,out] | timer | A pointer to a timer value used to time the marquee |
bool drawTextEllipsize | ( | const font_t * | font, |
paletteColor_t | color, | ||
const char * | text, | ||
int16_t | xOff, | ||
int16_t | yOff, | ||
int16_t | maxW, | ||
bool | center ) |
Draw text to the display that fits within a given length, replacing any overflowing text with "...".
font | The font to use for the text |
color | The color of the character to draw |
text | The text to draw to the display |
xOff | The x offset to draw the text at |
yOff | The y offset to draw the text at |
maxW | The maximum width of text to draw |
center | If true, when text is not ellipsize it will be centered within the box |
int16_t drawTextMulticolored | ( | const font_t * | font, |
const char * | text, | ||
int16_t | xOff, | ||
int16_t | yOff, | ||
const paletteColor_t * | colors, | ||
uint32_t | colorCount, | ||
uint32_t | segmentCount ) |
Draws text divided into any number of colored segments.
The entire length of text will be divided into colorCount
segments
font | The font to use for the text |
text | The text to draw to the display |
xOff | The x offset to draw the text at |
yOff | The y offset to draw the text at |
colors | An array of colors to use when drawing the text |
colorCount | The number of elements in the colors array |
segmentCount | The number of segments to divide the text into |