From b04d5702719eca30a95d1db2a927b6605ebd3477 Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Mon, 10 Feb 2025 01:12:55 -0700 Subject: Some fast math stuff added --- test/scanTest2.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'test/scanTest2.c') diff --git a/test/scanTest2.c b/test/scanTest2.c index 40c82fe..1a90bb7 100644 --- a/test/scanTest2.c +++ b/test/scanTest2.c @@ -7,6 +7,25 @@ Color lineScanner(uint16_t x, uint16_t y, uint32_t frameNumber) { - return (Color){.r = x % 100 == 1 ? 255 : 0, .g = 0, .b = 0, .a = 255}; + //uint8_t c = (x >> 8) + (uint8_t)(SLDJ_HYPOT2((x >> 9), (y >> 9)) * (frameNumber % 255)); + //uint8_t c = sin(x * DEG2RAD) * 256; + //uint8_t c = SLDJ_SIN(x % 360) * 256; + + uint8_t scale = random() % 2 + 7; + + float scaleCos = SLDJ_COS(((int)(x * RAD2DEG) >> scale) % 360); + float scaleSin = SLDJ_SIN(((int)(y * RAD2DEG) >> scale) % 360); + + uint8_t c1 = (x >> 8) + (uint8_t)(SLDJ_HYPOT2((x >> 8), (y >> 8)) * (frameNumber % 255)); + uint8_t c2 = (x >> 8) + (uint8_t)(SLDJ_HYPOT2(scaleCos, scaleSin) * (frameNumber % 255)); + uint8_t c3 = frameNumber + SLDJ_HYPOT2(((x - 32768) >> scale), ((y - 32768) >> scale)); + uint8_t c = c1 & c2 & c3; + + return (Color){ + .r = c, + .g = c - 127, + .b = c, + .a = 255 + }; } -- cgit v1.2.3