second eyecandy prototype is running nicely

This commit is contained in:
tth 2019-01-24 01:00:18 +01:00
parent dce67b491d
commit 2f5617d3b4
2 changed files with 48 additions and 10 deletions

View File

@ -10,6 +10,34 @@
int verbosity; int verbosity;
/* ---------------------------------------------------------------- */
void demo_vumetres(int nbl, int notused)
{
int loop, idx;
int hpos;
char ligne[100];
float value;
for (loop=0; loop<nbl; loop++) {
value = (float)loop / (float)nbl;
for (idx=0; idx<4; idx++) {
hpos = 5 * (idx+1);
sprintf(ligne, "%6.3f", value);
mvwaddstr(stdscr, hpos, 2, ligne);
vumetre_0(stdscr, hpos, 12, value, 60);
}
refresh();
usleep(200*1000);
}
}
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
void demo_waterfall(int nbl, int k) void demo_waterfall(int nbl, int k)
{ {
@ -61,15 +89,17 @@ endwin(); exit(0);
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
int opt; int opt;
int demonum = 0;
/* set some default values */ /* set some default values */
verbosity = 0; verbosity = 0;
while ((opt = getopt(argc, argv, "vy:")) != -1) {
while ((opt = getopt(argc, argv, "v")) != -1) {
switch (opt) { switch (opt) {
case 'v': verbosity++; break; case 'v': verbosity++; break;
case 'y': demonum = atoi(optarg); break;
default: default:
fprintf(stderr, "%s : uh ?", argv[0]); fprintf(stderr, "%s : uh ?", argv[0]);
exit(1); exit(1);
@ -78,7 +108,6 @@ while ((opt = getopt(argc, argv, "v")) != -1) {
} }
initscr(); initscr();
nonl(); cbreak(); noecho(); nonl(); cbreak(); noecho();
@ -86,7 +115,10 @@ keypad(stdscr, TRUE); /* acces aux touches 'curseur' */
fond_ecran(" Demonstrator "); fond_ecran(" Demonstrator ");
demo_waterfall(190000, 0); switch (demonum) {
case 0: demo_vumetres(666, 0); break;
case 1: demo_waterfall(666, 0); break;
}
/* /*
* plop, on a fini, restaurer la console * plop, on a fini, restaurer la console

View File

@ -17,19 +17,25 @@ int verbosity;
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int vumetre_0(WINDOW *win, int lig, int col, float val, int larg) int vumetre_0(WINDOW *win, int lig, int col, float val, int larg)
{ {
int foo; int foo, posc;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n", fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
__func__, win, lig, col, val, larg); __func__, win, lig, col, val, larg);
#endif #endif
posc = (int)(val * (float)larg);
for (foo=0; foo<larg; foo++) { for (foo=0; foo<larg; foo++) {
mvwaddch(win, lig-1, col+foo, '*'); mvwaddch(win, lig, col+foo, "-*"[foo < posc]);
if (foo & 1) {
mvwaddch(win, lig-1, col+foo, '\\');
mvwaddch(win, lig+1, col+foo, '/');
}
}
wrefresh(win); wrefresh(win);
}
return -1; return 0;
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */