add: Basic Font Rendering
This commit is contained in:
@@ -142,6 +142,46 @@ namespace frame::render
|
||||
{BottomRight.x, BottomRight.y - lw});
|
||||
}
|
||||
|
||||
void RenderTarget::DrawImage(Vector topLeft, Image const& image)
|
||||
{
|
||||
auto pos = topLeft;
|
||||
|
||||
for(auto y = 0; y < image.getHeight(); ++y)
|
||||
{
|
||||
for(auto x = 0; x < image.getWidth(); ++x)
|
||||
{
|
||||
DrawPixel({pos.x + x, pos.y + y}, (Color)image.at(x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector RenderTarget::DrawGlyph(Vector centerLine,
|
||||
font::Glyph const& g,
|
||||
Color color)
|
||||
{
|
||||
auto const& height = g.height;
|
||||
|
||||
Vector topleft = centerLine;
|
||||
topleft.x += g.x_offset;
|
||||
topleft.y += g.y_offset;
|
||||
|
||||
DrawImage(topleft, g.image);
|
||||
centerLine.x += g.advance;
|
||||
return centerLine;
|
||||
}
|
||||
|
||||
void RenderTarget::DrawText(std::string_view pText,
|
||||
Vector pCenterLineStart,
|
||||
font::Font const& pFont,
|
||||
uint8_t size)
|
||||
{
|
||||
auto pos = pCenterLineStart;
|
||||
for(auto c : pText)
|
||||
{
|
||||
pos = DrawGlyph(pos, pFont.getGlyph(size, c));
|
||||
}
|
||||
}
|
||||
|
||||
void RenderTarget::DrawPointsMirrorCircle(Vector const& center,
|
||||
Vector const& pos,
|
||||
Color color)
|
||||
|
||||
Reference in New Issue
Block a user