Add tinygl_draw_string
This commit is contained in:
+34
-1
@@ -177,10 +177,43 @@ void tinygl_draw_char (char ch, tinygl_point_t offset, bool rotate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Draw string (well, as much as possible) using current font.
|
||||
@param str string to draw
|
||||
@param offset coordinates of top left position
|
||||
@param rotate non-zero to rotate string
|
||||
@return number of whole characters drawn. */
|
||||
uint8_t tinygl_draw_string (const char *str, tinygl_point_t offset, bool rotate)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
|
||||
while (*str)
|
||||
{
|
||||
if (rotate)
|
||||
{
|
||||
if (offset.y + font->width > TINYGL_HEIGHT)
|
||||
break;
|
||||
tinygl_draw_char (*str, offset, 1);
|
||||
offset.y += font->width + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (offset.x + font->width > TINYGL_WIDTH)
|
||||
break;
|
||||
tinygl_draw_char (*str, offset, 0);
|
||||
offset.x += font->width + 1;
|
||||
}
|
||||
count++;
|
||||
str++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Display a character.
|
||||
@param ch character to display
|
||||
@return 1 if character fully displayed. */
|
||||
|
||||
@@ -153,6 +153,14 @@ void tinygl_font_set (font_t *pfont);
|
||||
void tinygl_draw_char (char ch, tinygl_point_t offset, bool rotate);
|
||||
|
||||
|
||||
/** Draw string (well, as much as possible) using current font.
|
||||
@param str string to draw
|
||||
@param offset coordinates of top left position
|
||||
@param rotate non-zero to rotate string
|
||||
@return number of whole characters drawn. */
|
||||
uint8_t tinygl_draw_string (const char *str, tinygl_point_t offset,
|
||||
bool rotate);
|
||||
|
||||
/** Draw point.
|
||||
@param point coordinates of point
|
||||
@param pixel_value pixel value to draw point. */
|
||||
|
||||
Reference in New Issue
Block a user