From 98fe08727bb41a6497002bcb42561e58e7cae642 Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 17 Jan 2020 08:09:19 -0500 Subject: [PATCH] fallen: open the curtain on patents.png --- doc/man/man1/notcurses-demo.1.md | 5 +++++ src/demo/fallin.c | 26 +++++++++++++++++++++++--- src/demo/sliding.c | 16 ---------------- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/doc/man/man1/notcurses-demo.1.md b/doc/man/man1/notcurses-demo.1.md index 81dbcc7c5..6795707c1 100644 --- a/doc/man/man1/notcurses-demo.1.md +++ b/doc/man/man1/notcurses-demo.1.md @@ -65,5 +65,10 @@ Proper display requires: * A monospaced font, and * Good Unicode support in your libc, font, and terminal emulator. +# BUGS + +If notcurses is built without FFmpeg, the following demos will fail immedaitely when specified: **xray**, +**eagle**, **chunli**, **fallin**, **view**, **outro**. + # SEE ALSO notcurses(3notcurses), ncurses(3ncurses), terminfo(5) diff --git a/src/demo/fallin.c b/src/demo/fallin.c index d4c9c6f07..501d86db7 100644 --- a/src/demo/fallin.c +++ b/src/demo/fallin.c @@ -11,7 +11,6 @@ drop_bricks(struct notcurses* nc, struct ncplane** arr, int arrcount){ struct timespec iterdelay; // 5 * demodelay total ns_to_timespec(timespec_to_ns(&demodelay) / arrcount / 2, &iterdelay); - ncplane_erase(notcurses_stdplane(nc)); // we've got a range of up to 10 total blocks falling at any given time. they // accelerate as they fall. [ranges, reange) covers the active range. int ranges = 0; @@ -23,7 +22,6 @@ drop_bricks(struct notcurses* nc, struct ncplane** arr, int arrcount){ // ahead and get it kicked off if(rangee - ranges + 1 < FALLINGMAX){ if(rangee < arrcount){ - ncplane_greyscale(arr[rangee]); speeds[rangee - ranges] = 1; ++rangee; } @@ -108,6 +106,7 @@ int fallin_demo(struct notcurses* nc){ // * maxy/maxx: maximum geometry of randomly-generated bricks // * newy/newx: actual geometry of current brick // * usey/usex: + ncplane_greyscale(notcurses_stdplane(nc)); for(int y = 0 ; y < dimy ; ++y){ int x = 0; while(x < dimx){ @@ -164,5 +163,26 @@ int fallin_demo(struct notcurses* nc){ } } free(usemap); - return drop_bricks(nc, arr, arrcount); + int averr = 0; + char* path = find_data("lamepatents.jpg"); + struct ncvisual* ncv = ncplane_visual_open(notcurses_stdplane(nc), path, &averr); + free(path); + if(ncv == NULL){ + return -1; + } + if(ncvisual_decode(ncv, &averr) == NULL){ + ncvisual_destroy(ncv); + return -1; + } + if(ncvisual_render(ncv, 0, 0, 0, 0)){ + ncvisual_destroy(ncv); + return -1; + } + notcurses_render(nc); + int ret = drop_bricks(nc, arr, arrcount); + assert(ncvisual_decode(ncv, &averr) == NULL); + assert(averr == AVERROR_EOF); + ncvisual_destroy(ncv); + ncplane_pulse(notcurses_stdplane(ncv), &demodelay, pulser); + return ret; } diff --git a/src/demo/sliding.c b/src/demo/sliding.c index fe5eac582..aa767eea6 100644 --- a/src/demo/sliding.c +++ b/src/demo/sliding.c @@ -160,21 +160,6 @@ int sliding_puzzle_demo(struct notcurses* nc){ int wastex = ((maxx - 2) - (CHUNKS_HORZ * chunkx)) / 2; struct ncplane* n = notcurses_stdplane(nc); ncplane_erase(n); - int averr = 0; - char* path = find_data("lamepatents.jpg"); - struct ncvisual* ncv = ncplane_visual_open(n, path, &averr); - free(path); - if(ncv == NULL){ - return -1; - } - if(ncvisual_decode(ncv, &averr) == NULL){ - ncvisual_destroy(ncv); - return -1; - } - if(ncvisual_render(ncv, 0, 0, 0, 0)){ - ncvisual_destroy(ncv); - return -1; - } const int chunkcount = CHUNKS_VERT * CHUNKS_HORZ; struct ncplane** chunks = malloc(sizeof(*chunks) * chunkcount); if(chunks == NULL){ @@ -240,7 +225,6 @@ int sliding_puzzle_demo(struct notcurses* nc){ ret = 0; done: - ncvisual_destroy(ncv); for(z = 0 ; z < chunkcount ; ++z){ ncplane_destroy(chunks[z]); }