Xyris  0.5
Graphics::Font Namespace Reference

Functions

void Draw (char c, uint32_t x, uint32_t y, uint32_t fore)
 
void Draw (char c, uint32_t x, uint32_t y, uint32_t fore, uint32_t back)
 

Function Documentation

◆ Draw() [1/2]

void Graphics::Font::Draw ( char  c,
uint32_t  x,
uint32_t  y,
uint32_t  fore 
)

Draw the character at the given coordinates in the given color.

Parameters
cCharacter to draw
xHorizontal position
yVertical position
foreCharacter hex color

Definition at line 157 of file font.cpp.

158 {
159  // Convert screen coordinates to pixel coordinates
160  x *= FONT_WIDTH;
161  y *= FONT_HEIGHT;
162  // Draw the font glyph
163  uint8_t fp = (uint8_t)c;
164  for (int fy = 0; fy <= FONT_HEIGHT; fy++) {
165  for (int fx = 0; fx <= FONT_WIDTH; fx++) {
166  if (fx != FONT_WIDTH && fy != FONT_HEIGHT && (fontData[fp][fy] & (1 << fx))) {
167  // Current position is part of the font glyph.
168  pixel(x + fx, y + fy, fore);
169  }
170  }
171  }
172 }
+ Here is the call graph for this function:

◆ Draw() [2/2]

void Graphics::Font::Draw ( char  c,
uint32_t  x,
uint32_t  y,
uint32_t  fore,
uint32_t  back 
)

Draw the character at the given coordinates in the given color.

Parameters
cCharacter to draw
xHorizontal position
yVertical position
foreCharacter foreground hex color
backCharacter background hex color

Definition at line 174 of file font.cpp.

175 {
176  // Convert screen coordinates to pixel coordinates
177  x *= FONT_WIDTH;
178  y *= FONT_HEIGHT;
179  // Draw the font glyph
180  uint8_t fp = (uint8_t)c;
181  for (int fy = 0; fy < 9; fy++) {
182  for (int fx = 0; fx < 9; fx++) {
183  if (fx != FONT_WIDTH && fy != FONT_HEIGHT && (fontData[fp][fy] & (1 << fx))) {
184  // Current position is part of the font glyph.
185  pixel(x + fx, y + fy, fore);
186  } else {
187  // Not part of the glyph. Draw background color.
188  pixel(x + fx, y + fy, back);
189  }
190  }
191  }
192 }
+ Here is the call graph for this function:
FONT_HEIGHT
#define FONT_HEIGHT
Definition: font.hpp:15
Graphics::pixel
void pixel(uint32_t x, uint32_t y, uint32_t color)
Draws a pixel at a given coordinate.
Definition: graphics.cpp:53
FONT_WIDTH
#define FONT_WIDTH
Definition: font.hpp:14