diff options
| author | raysan5 <raysan5@gmail.com> | 2016-03-06 19:28:58 +0100 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2016-03-06 19:28:58 +0100 |
| commit | d0e7195a16c50b23fd82e7ca7869cc07773ddba2 (patch) | |
| tree | d4d96c183bacd39aef0a4fce378f5ffdd1714a03 /src/textures.c | |
| parent | 7053724fd6209682f203b188c6f309214880b84f (diff) | |
| download | raylib-d0e7195a16c50b23fd82e7ca7869cc07773ddba2.tar.gz raylib-d0e7195a16c50b23fd82e7ca7869cc07773ddba2.zip | |
Added new functions to draw text on image
Diffstat (limited to 'src/textures.c')
| -rw-r--r-- | src/textures.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/textures.c b/src/textures.c index cb3113dc..e649df57 100644 --- a/src/textures.c +++ b/src/textures.c @@ -1090,6 +1090,25 @@ Image ImageTextEx(SpriteFont font, const char *text, int fontSize, int spacing, return imText; } +// Draw text (default font) within an image (destination) +void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color) +{ + ImageDrawTextEx(dst, position, GetDefaultFont(), text, fontSize, 0, color); +} + +// Draw text (custom sprite font) within an image (destination) +void ImageDrawTextEx(Image *dst, Vector2 position, SpriteFont font, const char *text, int fontSize, int spacing, Color color) +{ + Image imText = ImageTextEx(font, text, fontSize, spacing, color); + + Rectangle srcRec = { 0, 0, imText.width, imText.height }; + Rectangle dstRec = { (int)position.x, (int)position.y, imText.width, imText.height }; + + ImageDraw(dst, imText, srcRec, dstRec); + + UnloadImage(imText); +} + // Flip image vertically void ImageFlipVertical(Image *image) { |
