dos33fsprogs/gr-sim/rasterbars.c

73 lines
1.1 KiB
C
Raw Normal View History

2018-01-08 05:50:18 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include "gr-sim.h"
static int row_color[40];
#define ELEMENTS 16
int set_row_color(double offset, int color) {
int y,s;
y=16.0*sin((offset)*2.0*3.14/16.0);
if (y<0) s=-1; else if (y==0) s=0; else s=1;
row_color[y+18]=color;
row_color[y+s+18]=color;
return 0;
}
2018-01-08 05:50:18 +00:00
int main(int argc, char **argv) {
2018-01-08 05:50:18 +00:00
2018-01-13 05:59:53 +00:00
int ch,i=0,j,end=3;
2018-01-08 05:50:18 +00:00
grsim_init();
gr();
clear_screens();
2018-01-08 05:50:18 +00:00
while(1) {
/* clear old colors */
for(j=0;j<40;j++) row_color[j]=0;
2018-01-08 05:50:18 +00:00
gr();
set_row_color(i+1.75,14); // aqua
set_row_color(i+1.5,6); // med-blue
set_row_color(i+1.25,12); // light-green
set_row_color(i+1.0,4); // green
set_row_color(i+0.75,13); // yellow
set_row_color(i+0.5,9); // orange
set_row_color(i+0.25,11); // pink
set_row_color(i+0.0,1); // red
2018-01-08 05:50:18 +00:00
for(j=0;j<40;j++) {
if (row_color[j]) {
color_equals(row_color[j]);
hlin(0,0,40,j);
}
}
2018-01-08 05:50:18 +00:00
grsim_update();
ch=grsim_input();
if (ch=='q') exit(0);
usleep(100000);
2018-01-08 05:50:18 +00:00
i++;
2018-01-13 05:59:53 +00:00
if (i>ELEMENTS-1) {
i=0;
end--;
if (end==0) break;
}
2018-01-08 05:50:18 +00:00
}
return 0;
}