summaryrefslogtreecommitdiff
path: root/examples/rainbow.c
blob: 8439b0b5bdf24dd6576406c56d10036e677bc48b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <math.h>

#include "../sponge.h"

#define PI ((float)3.14159265358979323846)
#define SPEED (2.0f / 360.0f * 2 * PI)
static float angle = 0.0f;

void init() {}

void draw_frame(sponge_Texture c) {
    angle += SPEED;

    float rf = (sinf(angle) + 1.0f) * 255.0f / 2.0f;
    float gf = (sinf(angle + (PI * 2.0f / 3.0f)) + 1.0f) * 255.0f / 2.0f;
    float bf = (sinf(angle + (PI * 4.0f / 3.0f)) + 1.0f) * 255.0f / 2.0f;

    sponge_Color32 color;
    color.a = 0xFF;
    color.r = (((int)rf) & 0xFF);
    color.g = (((int)gf) & 0xFF);
    color.b = (((int)bf) & 0xFF);
    sponge_clear(c, color);
}