Skip to content

Commit

Permalink
ADDED: New function ColorIsEqual()
Browse files Browse the repository at this point in the history
  • Loading branch information
raysan5 committed Feb 29, 2024
1 parent 94c7991 commit 1e84506
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/raylib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,7 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, V
RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint); // Draws a texture (or part of it) that stretches or shrinks nicely

// 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 int ColorToInt(Color color); // Get hexadecimal value for a Color
RLAPI Vector4 ColorNormalize(Color color); // Get Color normalized as float [0..1]
Expand Down
10 changes: 10 additions & 0 deletions src/rtextures.c
Original file line number Diff line number Diff line change
Expand Up @@ -4453,6 +4453,16 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest,
}
}

// Check if two colors are equal
bool ColorIsEqual(Color col1, Color col2)
{
bool result = false;

if ((col1.r == col2.r) && (col1.g == col2.g) && (col1.b == col2.b) && (col1.a == col2.a)) result = true;

This comment has been minimized.

Copy link
@Elkantor

Elkantor Mar 1, 2024

Contributor

Why not just return this condition? Without the if statement.

This comment has been minimized.

Copy link
@raysan5

raysan5 Mar 1, 2024

Author Owner

It's just a personal preference, I prefer to keep a variable to see the result, I find it more visual.


return result;
}

// Get color with alpha applied, alpha goes from 0.0f to 1.0f
Color Fade(Color color, float alpha)
{
Expand Down

0 comments on commit 1e84506

Please sign in to comment.