summaryrefslogtreecommitdiff
path: root/examples/rainbow.c
blob: dac2fae4107153d3a1aac9cb0a933882b249708d (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 SPONGE_EXAMPLE_IMPLEMENTATION
#include "../example.h"

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

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);
}