blob: ac67115b37f44923a77a353dc34ff1e76dcbe3b5 (
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
44
45
|
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
typedef struct Color {
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
} Color;
Color lineScanner(uint16_t x, uint16_t y, uint32_t frameNumber)
{
uint8_t c = 0;
uint8_t scale = random() % 2 + 7;
if (frameNumber % 1024 >= 512)
{
uint8_t section = frameNumber % 300;
if (section >= 200)
{
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));
} else {
c = frameNumber + hypot((x - 32768) >> scale, (y - 32768) >> scale);
}
} else {
uint8_t c1 = (x >> 8) + (uint8_t)(hypot(x >> 8, y >> 8) * (frameNumber % 255));
uint8_t c2 = (x >> 8) + (uint8_t)(hypot(cos(x >> scale), sin(y >> scale)) * (frameNumber % 255));
uint8_t c3 = frameNumber + hypot((x - 32768) >> scale, (y - 32768) >> scale);
c = c1 & c2 & c3;
}
return (Color){
.r = (uint8_t)(sin(c) * 127),
.g = c - 127,
.b = c,
.a = 255
};
}
|