summaryrefslogtreecommitdiff
path: root/main.c
blob: 4327db5ed95b3776e2c69e00dfe8a19bb11e652b (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
#include <stdio.h>
#include <unistd.h>
#include <math.h>

#include "framebuffer.h"

int main(void) {
    term_init();
    fprintf(stderr, "%zux%zu\n", term_width, term_height);

    Framebuffer fb = fb_new(term_width, term_height);
    fb_fill(fb, P_RED);

    char c;
    const float k_x = 0.1;
    const float k_t = 0.1;
    size_t t = 0;
    while(1) {
        fb_fill(fb, P_RED);

        /* Sine wave */
        for (size_t x = 0; x < term_width; x++) {
            size_t y = ((sin(k_x * x + k_t * t) + 1.0) / 2 * term_height / 2) + (size_t)(term_height / 4);
            fb.fb[y][x] = P_CYAN;
        }

        fb_print(fb);

        if (get_input(c) != 0 && c == 'q') { break; };

        t++;
    }


    term_cleanup();
}