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
46
47
48
49
50
51
52
|
#include <locale.h>
#include <math.h>
#include <stdio.h>
#include <unistd.h>
#include "framebuffer.h"
int main(void) {
setlocale(LC_ALL,"");
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;
long text_x = 0, text_y = 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_vert_line(fb, x, y, term_height - 1, P_GREEN);
}
fb_text_no_bg(fb, text_x, text_y, "testing", C_BLACK);
fb_print(fb);
/* Handle input */
if (get_input(c) != 0) {
switch(c) {
case 'q': goto quit; break;
case 'h': text_x -= 1; break;
case 'l': text_x += 1; break;
case 'k': text_y -= 1; break;
case 'j': text_y += 1; break;
}
};
t++;
}
quit:
fb_free(&fb);
term_cleanup();
}
|