diff --git a/src/raylib.h b/src/raylib.h index 244e45e14..d88fe0d5f 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1455,6 +1455,8 @@ RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle // Color/pixel related functions RLAPI bool ColorIsEqual(Color col1, Color col2); // Check if two colors are equal RLAPI Color Fade(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f +RLAPI Rectangle ExpandRectangle(Rectangle rec, float expand); // Expand a rectangle uniformly +RLAPI Rectangle ShrinkRectangle(Rectangle rec, float shrink); // Shrink a rectangle uniformly RLAPI int ColorToInt(Color color); // Get hexadecimal value for a Color (0xRRGGBBAA) RLAPI Vector4 ColorNormalize(Color color); // Get Color normalized as float [0..1] RLAPI Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [0..1] diff --git a/src/rtextures.c b/src/rtextures.c index 17065822a..c11b2e8aa 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -4859,6 +4859,24 @@ Color Fade(Color color, float alpha) return result; } +// Expand a rectangle uniformly +Rectangle ExpandRectangle(Rectangle rec, float expand) +{ + rec.x -= expand / 2.0f; + rec.y -= expand / 2.0f; + rec.width += expand; + rec.height += expand; +} + +// Shrink a rectangle uniformly +Rectangle ShrinkRectangle(Rectangle rec, float shrink) +{ + rec.x += shrink / 2.0f; + rec.y += shrink / 2.0f; + rec.width -= shrink; + rec.height -= shrink; +} + // Get hexadecimal value for a Color int ColorToInt(Color color) {