You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
674 B
C
33 lines
674 B
C
5 years ago
|
#include "images.h"
|
||
|
|
||
|
Color color_new(int r, int g, int b) {
|
||
|
Color c;
|
||
|
c.r = r;
|
||
|
c.g = g;
|
||
|
c.b = b;
|
||
|
c.alpha = 1;
|
||
|
return c;
|
||
|
}
|
||
|
|
||
|
Color color_new_alpha(int r, int g, int b, float alpha) {
|
||
|
Color c;
|
||
|
c.r = r;
|
||
|
c.g = g;
|
||
|
c.b = b;
|
||
|
c.alpha = alpha;
|
||
|
return c;
|
||
|
}
|
||
|
|
||
|
void print_color(Color c) {
|
||
|
printf("color is: #%02hhX%02hhX%02hhX\n", c.r, c.g, c.b);
|
||
|
}
|
||
|
|
||
|
Color color_mix(Color c1, Color c2, float ratio) {
|
||
|
return color_new_alpha(
|
||
|
ratio * c1.r + ((1 - ratio) * c2.r),
|
||
|
ratio * c1.g + ((1 - ratio) * c2.g),
|
||
|
ratio * c1.b + ((1 - ratio) * c2.b),
|
||
|
ratio * c1.alpha + ((1 - ratio) * c2.alpha)
|
||
|
);
|
||
|
}
|