Skip to content

Commit 122e378

Browse files
committed
ADDED: New image drawing functions, aligned with texture/text drawing -WIP-
The new functions are direct maps of the Texture2D equivalents, they can be useful for a future mapping Texture2D --> Image; an alternative 2d software renderer...
1 parent 2c24ca1 commit 122e378

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

src/raylib.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,19 +1431,23 @@ RLAPI void ImageDrawTriangleStrip(Image *dst, const Vector2 *points, int pointCo
14311431
RLAPI void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color); // Draw rectangle within an image
14321432
RLAPI void ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color); // Draw rectangle within an image (Vector version)
14331433
RLAPI void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color); // Draw rectangle within an image
1434+
RLAPI void ImageDrawRectanglePro(Image *dst, Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters within and image
14341435
RLAPI void ImageDrawRectangleLines(Image *dst, int posX, int posY, int width, int height, Color color); // Draw rectangle lines within an image
14351436
RLAPI void ImageDrawRectangleLinesEx(Image *dst, Rectangle rec, int thick, Color color); // Draw rectangle lines within an image with line thickness
1437+
RLAPI void ImageDrawRectangleGradientEx(Image *dst, Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw rectangle with gradient colors within an image, counter-clockwise color order
14361438
RLAPI void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color); // Draw a filled circle within an image
14371439
RLAPI void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color); // Draw a filled circle within an image (Vector version)
14381440
RLAPI void ImageDrawCircleLines(Image *dst, int centerX, int centerY, int radius, Color color); // Draw circle outline within an image
14391441
RLAPI void ImageDrawCircleLinesV(Image *dst, Vector2 center, int radius, Color color); // Draw circle outline within an image (Vector version)
14401442
RLAPI void ImageDrawCircleGradient(Image *dst, Vector2 center, float radius, Color inner, Color outer); // Draw a gradient-filled circle within an image
14411443

14421444
RLAPI void ImageDrawImage(Image *dst, Image src, int posX, int posY, Color tint); // Draw an image within an image
1445+
RLAPI void ImageDrawImageEx(Image *dst, Image src, Vector2 position, float rotation, float scale, Color tint); // Draw an image with scaling and rotation within an image
14431446
RLAPI void ImageDrawImageRec(Image *dst, Image src, Rectangle srcRec, Vector2 position, Color tint); // Draw a part of an image defined by a rectangle within an image
14441447
RLAPI void ImageDrawImagePro(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Vector2 origin, float rotation, Color tint); // Draw a part of an image defined by a rectangle into destination rectangle, with scaling and rotation, within an image
14451448
RLAPI void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) within an image (destination)
14461449
RLAPI void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text (custom sprite font) within an image (destination)
1450+
RLAPI void ImageDrawTextPro(Image *dst, Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint); // Draw text using Font and pro parameters (rotation)
14471451

14481452
// Texture loading functions
14491453
// NOTE: These functions require GPU access

src/rtextures.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3918,6 +3918,12 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
39183918
}
39193919
}
39203920

3921+
// Draw a color-filled rectangle with pro parameters within and image
3922+
void ImageDrawRectanglePro(Image *dst, Rectangle rec, Vector2 origin, float rotation, Color color)
3923+
{
3924+
// TODO: NEW: Implement ImageDrawRectanglePro()
3925+
}
3926+
39213927
// Draw rectangle lines within an image
39223928
void ImageDrawRectangleLines(Image *dst, int posX, int posY, int width, int height, Color color)
39233929
{
@@ -3934,6 +3940,12 @@ void ImageDrawRectangleLinesEx(Image *dst, Rectangle rec, int thick, Color color
39343940
ImageDrawRectangle(dst, (int)rec.x, (int)(rec.y + rec.height - thick), (int)rec.width, thick, color);
39353941
}
39363942

3943+
// Draw rectangle with gradient colors within an image, counter-clockwise color order
3944+
void ImageDrawRectangleGradientEx(Image *dst, Rectangle rec, Color col1, Color col2, Color col3, Color col4)
3945+
{
3946+
// TODO: NEW: Implement ImageDrawRectangleGradientEx()
3947+
}
3948+
39373949
// Draw circle within an image
39383950
void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color)
39393951
{
@@ -4001,7 +4013,7 @@ void ImageDrawCircleLinesV(Image *dst, Vector2 center, int radius, Color color)
40014013
// Draw a gradient-filled circle within an image
40024014
void ImageDrawCircleGradient(Image *dst, Vector2 center, float radius, Color inner, Color outer)
40034015
{
4004-
// TODO: Implement gradient circle drawing
4016+
// TODO: NEW: Implement ImageDrawCircleGradient()
40054017
}
40064018

40074019
// Draw an image within an image
@@ -4012,6 +4024,12 @@ void ImageDrawImage(Image *dst, Image src, int posX, int posY, Color tint)
40124024
ImageDrawImagePro(dst, src, srcRec, dstRec, (Vector2){ 0 }, 0.0f, tint);
40134025
}
40144026

4027+
// Draw an image with scaling and rotation within an image
4028+
void ImageDrawImageEx(Image *dst, Image src, Vector2 position, float rotation, float scale, Color tint)
4029+
{
4030+
// TODO: NEW: Implement ImageDrawImageEx()
4031+
}
4032+
40154033
// Draw a part of an image defined by a rectangle within an image
40164034
void ImageDrawImageRec(Image *dst, Image src, Rectangle srcRec, Vector2 position, Color tint)
40174035
{
@@ -4020,8 +4038,7 @@ void ImageDrawImageRec(Image *dst, Image src, Rectangle srcRec, Vector2 position
40204038
}
40214039

40224040
// Draw a part of an image defined by a rectangle into destination rectangle, with scaling and rotation, within an image
4023-
// NOTE: Color tint is applied to source image
4024-
// TODO: WARNING: origin and rotation are not implemented
4041+
// TODO: REVIEW: ImageDrawImagePro(), implement origin and rotation for image drawing
40254042
void ImageDrawImagePro(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Vector2 origin, float rotation, Color tint)
40264043
{
40274044
// Security check to avoid program crash
@@ -4199,6 +4216,12 @@ void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position,
41994216
UnloadImage(imText);
42004217
}
42014218

4219+
// Draw text using Font and pro parameters (rotation)
4220+
void ImageDrawTextPro(Image *dst, Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint)
4221+
{
4222+
// TODO: NEW: Implement ImageDrawImageEx()
4223+
}
4224+
42024225
//------------------------------------------------------------------------------------
42034226
// Texture loading functions
42044227
//------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)