aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornathansmith117 <nathansmith117@sdf.org>2025-02-10 08:12:55 +0000
committernathansmith117 <nathansmith117@sdf.org>2025-02-10 08:12:55 +0000
commitb04d5702719eca30a95d1db2a927b6605ebd3477 (patch)
treec388a6b152c117e2903e7acf63054211739e6df4 /test
parentfe9b718f8978cfd792f7303214b2dd45172b8d4b (diff)
downloadsldj-b04d5702719eca30a95d1db2a927b6605ebd3477.tar.gz
sldj-b04d5702719eca30a95d1db2a927b6605ebd3477.tar.bz2
sldj-b04d5702719eca30a95d1db2a927b6605ebd3477.zip
Some fast math stuff added
Diffstat (limited to 'test')
-rw-r--r--test/scanTest1.c4
-rw-r--r--test/scanTest2.c21
2 files changed, 22 insertions, 3 deletions
diff --git a/test/scanTest1.c b/test/scanTest1.c
index 19d78b5..c673e04 100644
--- a/test/scanTest1.c
+++ b/test/scanTest1.c
@@ -16,9 +16,9 @@ Color lineScanner(uint16_t x, uint16_t y, uint32_t frameNumber)
if (section >= 200)
{
- c = (x >> 8) + (uint8_t)(hypot(x >> 8, y >> 8) * (frameNumber % 255));
+ c = (x >> 8) + (uint8_t)(hypot(x >> 8, y >> 8) * (frameNumber % 255));
} else if (section >= 100) {
- c = (x >> 8) + (uint8_t)(hypot(cos(x >> scale), sin(y >> scale)) * (frameNumber % 255));
+ c = (x >> 8) + (uint8_t)(hypot(cos(x >> scale), sin(y >> scale)) * (frameNumber % 255));
} else {
c = frameNumber + hypot((x - 32768) >> scale, (y - 32768) >> scale);
}
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
+ };
}