Rectangle uniform scaling
New "ExpandRectangle" and "ShrinkRectangle" functions to save repetitive tasks.
This commit is contained in:
parent
48d690d8ad
commit
8cad35a757
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user