Skip to content
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

Merged
merged 4 commits into from
Sep 15, 2024

Conversation

SusgUY446
Copy link
Contributor

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

@veins1
Copy link
Contributor

veins1 commented Sep 9, 2024

If this ends up being approved by Ray, what do you think about naming it ColorLerp instead?

@raysan5
Copy link
Owner

raysan5 commented Sep 9, 2024

@SusgUY446 @veins1 It could be added as ColorLerp() in the Color*() functions section, seems more appropiate

@SusgUY446
Copy link
Contributor Author

why is a Color* more appropiate when most functions need a Color not a pointer to one

@raysan5
Copy link
Owner

raysan5 commented Sep 10, 2024

@SusgUY446 I was not referring to a pointer, I was referring to ColorName() functions group, for naming consistency.

@SusgUY446
Copy link
Contributor Author

oh okay.

src/rtextures.c Outdated Show resolved Hide resolved
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};
Copy link
Owner

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;}
Copy link
Owner

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);
Copy link
Owner

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/raylib.h Outdated Show resolved Hide resolved
src/rtextures.c Outdated
@@ -4985,6 +4985,27 @@ Vector3 ColorToHSV(Color color)
return hsv;
}

/*
Copy link
Owner

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.

@raysan5
Copy link
Owner

raysan5 commented Sep 11, 2024

@SusgUY446 Please, could you review the mentioned points?

@SusgUY446
Copy link
Contributor Author

okay

@raysan5 raysan5 merged commit ddc523f into raysan5:master Sep 15, 2024
@raysan5
Copy link
Owner

raysan5 commented Sep 15, 2024

@SusgUY446 Thanks for the improvement, I'll review code formatting...

raysan5 added a commit that referenced this pull request Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants