first start of fallin' demo

pull/287/head
nick black 5 years ago committed by Nick Black
parent 2783a1b503
commit 7860e1eace

@ -56,7 +56,7 @@ At any time, press 'q' to quit. The demo is best run in at least a 80x45 termina
**-V**: Print the program name and version, and exit with success.
demospec: Select which demos to run, and what order to run them in. The default is **ixetcgswubvlpo**. See above for a list of demos.
demospec: Select which demos to run, and what order to run them in. The default is **ixetcgpwubvlfso**. See above for a list of demos.
# NOTES
Proper display requires:

@ -21,7 +21,7 @@ static demoresult* results;
static char datadir[PATH_MAX];
static atomic_bool interrupted = ATOMIC_VAR_INIT(false);
static const char DEFAULT_DEMO[] = "ixetcgswubvlpo";
static const char DEFAULT_DEMO[] = "ixetcgpwubvlfso";
void interrupt_demo(void){
atomic_store(&interrupted, true);
@ -201,7 +201,7 @@ static const char* demonames[26] = {
"chunli",
"",
"eagle",
"",
"fallin",
"grid",
"",
"intro",
@ -259,6 +259,7 @@ ext_demos(struct notcurses* nc, const char* demos){
case 'c': ret = chunli_demo(nc); break;
case 'g': ret = grid_demo(nc); break;
case 'l': ret = luigi_demo(nc); break;
case 'f': ret = fallin_demo(nc); break;
case 'v': ret = view_demo(nc); break;
case 'e': ret = eagle_demo(nc); break;
case 'x': ret = xray_demo(nc); break;

@ -1,6 +1,27 @@
#include "demo.h"
int fallin_demo(struct notcurses* nc){
// make a copy of the standard plane so that we don't need rederive the
// world in the event of a resize event
struct ncplane* ndup = ncplane_dup(notcurses_stdplane(nc), NULL);
if(!ndup){
return -1;
}
ncplane_erase(notcurses_stdplane(nc));
int dimx, dimy, atotal;
ncplane_dim_yx(ndup, &dimy, &dimx);
atotal = dimy * dimx;
// FIXME shuffle up a list of all coordinates, then walk through them. each
// one ought be turned into its own small ncplane, erased from ndup, and the
// plane set falling.
while(atotal--){
if(notcurses_render(nc)){
ncplane_destroy(ndup);
return -1;
}
}
if(ncplane_destroy(ndup)){
return -1;
}
return 0;
}

@ -0,0 +1,40 @@
#include <cstdio>
#include <cstdlib>
#include <clocale>
#include <cassert>
#include <unistd.h>
#include <notcurses.h>
int main(int argc, char** argv){
setlocale(LC_ALL, "");
notcurses_options opts{};
opts.inhibit_alternate_screen = true;
struct notcurses* nc;
if((nc = notcurses_init(&opts, stdout)) == nullptr){
return EXIT_FAILURE;
}
struct ncplane* n = notcurses_stdplane(nc);
int dimx, dimy;
ncplane_dim_yx(n, &dimy, &dimx);
int averr;
auto ncv = ncplane_visual_open(n, "../data/dsscaw-purp.png", &averr);
if(!ncv){
goto err;
}
if(!ncvisual_decode(ncv, &averr)){
goto err;
}
if(ncvisual_render(ncv, 0, 0, 0, 0)){
goto err;
}
if(notcurses_render(nc)){
goto err;
}
sleep(1);
return notcurses_stop(nc) ? EXIT_FAILURE : EXIT_SUCCESS;
err:
notcurses_stop(nc);
return EXIT_FAILURE;
}
Loading…
Cancel
Save