blob: 32c4d86fd266244c7e62fc4823b76e0cb615457b (
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
|
#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;
if (frameNumber % 255 >= 127)
{
c = (x >> 8) + (uint8_t)(hypot(x >> 9, y >> 9) * (frameNumber % 255));
} else {
c = (x >> 8) + (uint8_t)(hypot(cos(x >> 9), sin(y >> 9)) * (frameNumber % 255));
}
return (Color){
.r = (uint8_t)(sin(c) * 127),
.g = c - 127,
.b = c,
.a = 255
};
}
|