FabGL
ESP32 VGA Controller and Graphics Library
|
void fabgl::CanvasClass::drawGlyph | ( | int | X, |
int | Y, | ||
int | width, | ||
int | height, | ||
uint8_t const * | data, | ||
int | index = 0 |
||
) |
Draw a glyph at specified position.
A Glyph is a monochrome bitmap (1 bit per pixel) that can be painted using pen (foreground) and brush (background) colors. Various drawing options can be set using CanvasClass.setGlyphOptions() method. Glyphs are used by TerminalClass to render characters.
X | Horizontal coordinate where to draw the glyph. |
Y | Vertical coordinate where to draw the glyph. |
width | Horizontal size of the glyph. |
height | Vertical size of the glyph. |
data | Memory buffer containing the glyph. Each line is byte aligned. The size must be "(width + 7) / 8 * height" (integer division!). |
index | Optional index inside data. Use when the buffer contains multiple glyphs. |
Example:
// draw an 'A' using the predefined font to fit 80x25 screen text Canvas.setPenColor(Color::BrightGreen); const fabgl::FontInfo * f = Canvas.getPresetFontInfo(80, 25); Canvas.drawGlyph(0, 0, f->width, f->height, f->data, 0x41); // draw a 12x8 sprite const uint8_t enemy[] = { 0x0f, 0x00, 0x7f, 0xe0, 0xff, 0xf0, 0xe6, 0x70, 0xff, 0xf0, 0x39, 0xc0, 0x66, 0x60, 0x30, 0xc0, }; Canvas.setPenColor(Color::BrightYellow); Canvas.drawGlyph(50, 80, 12, 8, enemy);