diff options
Diffstat (limited to 'src/screen.c')
-rw-r--r-- | src/screen.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/screen.c b/src/screen.c index 6f682ae..609797c 100644 --- a/src/screen.c +++ b/src/screen.c @@ -20,7 +20,7 @@ struct hsv { uint16_t v; }; -static uint32_t *buffer = NULL; +static volatile uint32_t *buffer = NULL; static uint32_t width, height; static uint8_t bit_depth; @@ -39,7 +39,12 @@ static float fabs(float f) { return f > 0 ? f : -f; } -static struct rgb htor(struct hsv hsv) { +static struct rgb gethsv(uint16_t a, uint16_t xp, uint16_t yp) { + struct hsv hsv = { + .h = a, + .s = xp * 100.0 / width, + .v = (height - yp) * 100.0 / height, + }; struct rgb rgb; float s = hsv.s / 100.0; float v = hsv.v / 100.0; @@ -69,14 +74,16 @@ static struct rgb htor(struct hsv hsv) { return rgb; } -static struct rgb get_color(uint16_t a, uint16_t x, uint16_t y) { - struct hsv hsv = { - .h = a, - .s = x * 100.0 / width, - .v = y * 100.0 / height, - }; - return htor(hsv); -} +//static struct rgb getsrgb(uint16_t x, uint16_t y) { +// struct rgb color;// = get_color(angle, x, height - y); +// double _x = (double) x / width; +// double _y = (double) y / height; +// double _z = (2 - _x - _y) / 2; +// color.r = _x * 255; +// color.g = _y * 255; +// color.b = _z * 255; +// return color; +//} void screen_init(void) { angle = 0; @@ -89,7 +96,7 @@ void screen_init(void) { void screen_redraw(void) { for (uint16_t y = 0; y < height; y++) { for (uint16_t x = 0; x < width; x++) { - struct rgb color = get_color(angle, x, height - y); + struct rgb color = gethsv(angle, x, y); set_pixel(color, x, y); } } |