-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rtextures] add MixColors. a function to mix 2 colors together #4310
Conversation
… and Line 4995 in rtextures.c)
If this ends up being approved by Ray, what do you think about naming it ColorLerp instead? |
@SusgUY446 @veins1 It could be added as |
why is a Color* more appropiate when most functions need a Color not a pointer to one |
@SusgUY446 I was not referring to a pointer, I was referring to |
oh okay. |
src/rtextures.c
Outdated
set d to 0.5 to have both colors balanced | ||
*/ | ||
Color ColorLerp(Color color1, Color color2, float d) { | ||
Color newColor = { 0, 0, 0, 0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, review coding conventions, last braket requires a space before it.
src/rtextures.c
Outdated
*/ | ||
Color ColorLerp(Color color1, Color color2, float d) { | ||
Color newColor = { 0, 0, 0, 0}; | ||
if (d < 0) {d=0.0f;} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, review naming conventions, spacing is wrong.
src/rtextures.c
Outdated
if (d < 0) {d=0.0f;} | ||
else if(d>1) {d=1.0f;} | ||
|
||
newColor.r = (unsigned char)((1.0f-d) * color1.r + d * color2.r); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, review naming conventions, spacing is wrong.
src/rtextures.c
Outdated
@@ -4985,6 +4985,27 @@ Vector3 ColorToHSV(Color color) | |||
return hsv; | |||
} | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, could you review the comment to be consistent with the other color functions. No functions use that many comment lines and neither /* */ comments.
@SusgUY446 Please, could you review the mentioned points? |
okay |
@SusgUY446 Thanks for the improvement, I'll review code formatting... |
The functions takes 2 Colors and a Float t as input. The float t is used to set what color is more dominant.
t=0.0f - color1 is more dominant
t=0.5f - both colors are equally dominant (best choice from my testing)
t=1.0f - color2 is more dominant