FabGL
ESP32 Display Controller and Graphics Library

◆ drawGlyph()

void drawGlyph ( int  X,
int  Y,
int  width,
int  height,
uint8_t const *  data,
int  index = 0 
)

Draws 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 Canvas.setGlyphOptions() method.
Glyphs are used by Terminal to render characters.

Parameters
XHorizontal coordinate where to draw the glyph.
YVertical coordinate where to draw the glyph.
widthHorizontal size of the glyph.
heightVertical size of the glyph.
dataMemory buffer containing the glyph. Each line is byte aligned. The size must be "(width + 7) / 8 * height" (integer division!).
indexOptional index inside data. Use when the buffer contains multiple glyphs.

Example:

// draw an 'A' using the predefined 8x8 font
Canvas.setPenColor(Color::BrightGreen);
const fabgl::FontInfo * f = &fabgl::FONT_8x8;
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);

Definition at line 332 of file canvas.cpp.