diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -1,3 +1,4 @@ +#include <math.h> #include <SDL.h> #include "init.h" #include "logging.h" @@ -61,14 +62,29 @@ main(void) render_area_to_viewport(a, vp); { float step; - for (step = 1.0; step >= 0.25; step -= 0.00390625) { + int y_start, y_end; + for (step = 0.0; step < 12.57; step += 0.006136) { for (i = 0; i < 256; ++i) { - colors[i].r = (i % 8) * 36; - colors[i].g = (i % 64 / 8) * 36; - colors[i].b = (i / 64) * 85; - colors[i].r *= step; - colors[i].g *= step; - colors[i].b *= step; + /* + * ((cos(x) + 1) / 2) => [0,1] + * y = ((cos(x) + 1) / 2) * + * (y_end - y_start) + y_start + */ + + y_start = (i % 8) * 36; + y_end = y_start / 4; + colors[i].r = ((cos(step) + 1) / 2) * + (y_end - y_start) + y_start; + + y_start = (i % 64 / 8) * 36; + y_end = y_start / 4; + colors[i].g = ((cos(step) + 1) / 2) * + (y_end - y_start) + y_start; + + y_start = (i / 64) * 85; + y_end = y_start / 4; + colors[i].b = ((cos(step) + 1) / 2) * + (y_end - y_start) + y_start; } if (!SDL_SetPalette(vp->screen, SDL_LOGPAL, colors, 0, 256)) { warn("Failed to set palette"); |