Graphics: Add drawHLine and drawVLine functions

replace/244bab46422374f28f628c2c963f38c5ead16f3f
Federico Amedeo Izzo 2020-11-18 16:56:32 +01:00
rodzic 0b8bb486a4
commit f2d9db024c
3 zmienionych plików z 41 dodań i 0 usunięć

Wyświetl plik

@ -172,6 +172,23 @@ void gfx_setPixel(point_t pos, color_t color);
*/
void gfx_drawLine(point_t start, point_t end, color_t color);
/**
* Draw a horizontal line with specified vertical position and width.
* @param y: vertical position, in pixel coordinates.
* @param height: line height, in pixel coordinates.
* @param color: line color, in color_t format.
*/
void gfx_drawHLine(uint16_t y, uint16_t height, color_t color);
/**
* Draw a vertical line with specified horizontal position and width.
* @param x: horizontal position, in pixel coordinates.
* @param width: line width, in pixel coordinates.
* @param color: line color, in color_t format.
*/
void gfx_drawVLine(uint16_t x, uint16_t width, color_t color);
/**
* Draw a rectangle of specified width, height and color.
* @param width: rectangle width, in pixels, borders included.

Wyświetl plik

@ -157,6 +157,18 @@ void gfx_drawRect(point_t start, uint16_t width, uint16_t height, color_t color,
}
}
void gfx_drawHLine(uint16_t y, uint16_t height, color_t color)
{
point_t start = {0, y};
gfx_drawRect(start, SCREEN_WIDTH, height, color, 1);
}
void gfx_drawVLine(uint16_t x, uint16_t width, color_t color)
{
point_t start = {x, 0};
gfx_drawRect(start, width, SCREEN_HEIGHT, color, 1);
}
/**
* Compute the pixel size of the first text line
* @param f: font used as the source of glyphs

Wyświetl plik

@ -146,6 +146,18 @@ void gfx_drawRect(point_t start, uint16_t width, uint16_t height, color_t color,
}
}
void gfx_drawHLine(uint16_t y, uint16_t height, color_t color)
{
point_t start = {0, y};
gfx_drawRect(start, SCREEN_WIDTH, height, color, 1);
}
void gfx_drawVLine(uint16_t x, uint16_t width, color_t color)
{
point_t start = {x, 0};
gfx_drawRect(start, width, SCREEN_HEIGHT, color, 1);
}
/**
* Compute the pixel size of the first text line
* @param f: font used as the source of glyphs