aboutsummaryrefslogtreecommitdiffstats
path: root/test/scanTest3.c
blob: 29559c32f3463e709e05b061790ba18c1bef77bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#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 = 102;

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 c = SLDJ_RANDOM16(s) >> 8;
    //uint8_t c = SLDJ_RANDOM32(s) >> 24;
    //uint8_t c = random();
    
    return (Color){
        .r = c * 10,
        .g = c + 127,
        .b = c,
        .a = 255
    };
}