Graphics: Add drawHLine and drawVLine functions

This commit is contained in:
Federico Amedeo Izzo 2020-11-18 16:56:32 +01:00
parent 0b8bb486a4
commit f2d9db024c
3 changed files with 41 additions and 0 deletions

View File

@ -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.

View File

@ -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

View File

@ -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