Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static struct colour rainbow(double x)
- {
- double red, green, blue;
- struct colour colour;
- red = 4.0 * x - 2.0;
- red = clip(red);
- if (x < 0.5)
- green = 4.0 * x;
- else
- green = (-4.0) * x + 4;
- green = clip(green);
- blue = (-4.0) * x + 2.0;
- blue = clip(blue);
- colour.r = (unsigned char)round(red * 255.0);
- colour.g = (unsigned char)round(green * 255.0);
- colour.b = (unsigned char)round(blue * 255.0);
- return colour;
- }
- static struct colour heat(double x)
- {
- double red, green, blue;
- struct colour colour;
- red = sqrt(x);
- red = clip(red);
- green = pow(x,3);
- green = clip(green);
- blue = 1 - pow(x * 4 - 1, 2);
- blue = clip(blue);
- colour.r = (unsigned char)round(red * 255.0);
- colour.g = (unsigned char)round(green * 255.0);
- colour.b = (unsigned char)round(blue * 255.0);
- return colour;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement