diff options
author | nathansmith117 <nathansmith117@sdf.org> | 2025-02-10 13:18:18 +0000 |
---|---|---|
committer | nathansmith117 <nathansmith117@sdf.org> | 2025-02-10 13:18:18 +0000 |
commit | db6e56cab84f004d8cee833b197d0cfc52014cd4 (patch) | |
tree | bbb53dfb0216aa87eabc5e24b6a2c0a81fa6251f /test/scanTest3.c | |
parent | b04d5702719eca30a95d1db2a927b6605ebd3477 (diff) | |
download | sldj-db6e56cab84f004d8cee833b197d0cfc52014cd4.tar.gz sldj-db6e56cab84f004d8cee833b197d0cfc52014cd4.tar.bz2 sldj-db6e56cab84f004d8cee833b197d0cfc52014cd4.zip |
Playing around with faster random numbers
Diffstat (limited to 'test/scanTest3.c')
-rw-r--r-- | test/scanTest3.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/scanTest3.c b/test/scanTest3.c new file mode 100644 index 0000000..1a0c3ec --- /dev/null +++ b/test/scanTest3.c @@ -0,0 +1,40 @@ +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <math.h> +#include <time.h> + +#include "libsldj/util.h" + +uint8_t lastValue = 200; + +// Rerendered noise. +#define VALUES_SIZE 65536 +uint8_t values[VALUES_SIZE]; + +void loadContext(SldjContext context) +{ + srandom(time(NULL)); + + for (int i = 0; i < VALUES_SIZE; ++i) + { + values[i] = random() % 256; + } +} + +int s = 100; + +Color lineScanner(uint16_t x, uint16_t y, uint32_t frameNumber) +{ + // Shifts around the noise to make it look better. + uint8_t c = values[((x + (frameNumber >> 2)) + (y << 1)) % VALUES_SIZE]; + uint8_t b = frameNumber + SLDJ_HYPOT2(((x - 32768) >> 6), ((y - 32768) >> 6)); + + return (Color){ + .r = (c + b) << 1, + .g = b, + .b = c, + .a = 255 + }; +} + |