Add Framebuffer.rect(), .hline(), .vline()
This commit is contained in:
parent
2d7bf5197f
commit
9e7c3ee676
@ -54,6 +54,57 @@ struct Framebuffer
|
||||
memset32(m_buffer, color, m_buffer_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a solid rectangle on the framebuffer.
|
||||
*
|
||||
* @param x X coordinate of left side of rectangle.
|
||||
* @param y Y coordinate of bottom side of rectangle.
|
||||
* @param width Width of rectangle.
|
||||
* @param height Height of rectangle.
|
||||
* @param color Color of rectangle.
|
||||
*/
|
||||
void rect(size_t x, size_t y, size_t width, size_t height, uint color)
|
||||
{
|
||||
for (size_t iy = 0u; iy < height; iy++)
|
||||
{
|
||||
size_t buffer_index = buffer_index(x, y);
|
||||
memset32(&m_buffer[buffer_index], color, width);
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a horizontal line.
|
||||
*
|
||||
* @param x X coordinate of left side of line.
|
||||
* @param y Y coordinate of line.
|
||||
* @param width Width of line.
|
||||
* @param color Color of line.
|
||||
*/
|
||||
void hline(size_t x, size_t y, size_t width, uint color)
|
||||
{
|
||||
size_t buffer_index = buffer_index(x, y);
|
||||
memset32(&m_buffer[buffer_index], color, width);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a vertical line.
|
||||
*
|
||||
* @param x X coordinate of line.
|
||||
* @param y Y coordinate of bottom of line.
|
||||
* @param height Height of line.
|
||||
* @param color Color of line.
|
||||
*/
|
||||
void vline(size_t x, size_t y, size_t height, uint color)
|
||||
{
|
||||
size_t buffer_index = buffer_index(x, y);
|
||||
for (size_t iy = 0u; iy < height; iy++)
|
||||
{
|
||||
m_buffer[buffer_index] = color;
|
||||
buffer_index -= m_stride;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Blit an 8-bit alpha bitmap to the framebuffer.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user