diff --git a/src/demo/demo.c b/src/demo/demo.c index 442aa6936..cb646dd32 100644 --- a/src/demo/demo.c +++ b/src/demo/demo.c @@ -341,6 +341,10 @@ handle_opts(int argc, char** argv, notcurses_options* opts, bool* use_hud){ fprintf(stderr, "Couldn't get a float from %s\n", optarg); usage(*argv, EXIT_FAILURE); } + if(f <= 0){ + fprintf(stderr, "Invalid multiplier: %f\n", f); + usage(*argv, EXIT_FAILURE); + } uint64_t ns = f * GIG; demodelay.tv_sec = ns / GIG; demodelay.tv_nsec = ns % GIG; diff --git a/src/demo/witherworm.c b/src/demo/witherworm.c index 12bb44864..e1b7b17ad 100644 --- a/src/demo/witherworm.c +++ b/src/demo/witherworm.c @@ -71,18 +71,13 @@ lighten(struct ncplane* n, cell* c, int distance, int y, int x){ r += rand() % ((r + 16) / (5 * distance + 1) + 1); g += rand() % ((g + 16) / (5 * distance + 1) + 1); b += rand() % ((b + 16) / (5 * distance + 1) + 1); - if(r > 255) r = 255; - if(g > 255) g = 255; - if(b > 255) b = 255; - if(cell_set_fg_rgb(c, r, g, b)){ - return -1; - } + cell_set_fg_rgb_clipped(c, r, g, b); return ncplane_putc_yx(n, y, x, c); } static void surrounding_cells(struct ncplane* n, cell* cells, int y, int x){ - ncplane_at_yx(n, y - 1, x - 1, &cells[0]); + /*ncplane_at_yx(n, y - 1, x - 1, &cells[0]); ncplane_at_yx(n, y - 1, x, &cells[1]); ncplane_at_yx(n, y - 1, x + 1, &cells[2]); ncplane_at_yx(n, y, x + 1, &cells[3]); @@ -93,13 +88,14 @@ surrounding_cells(struct ncplane* n, cell* cells, int y, int x){ ncplane_at_yx(n, y - 2, x, &cells[8]); ncplane_at_yx(n, y + 2, x, &cells[9]); ncplane_at_yx(n, y, x - 2, &cells[10]); - ncplane_at_yx(n, y, x + 2, &cells[11]); + ncplane_at_yx(n, y, x + 2, &cells[11]);*/ ncplane_at_yx(n, y, x, &cells[12]); } static int lightup_surrounding_cells(struct ncplane* n, const cell* cells, int y, int x){ cell c = CELL_TRIVIAL_INITIALIZER; + /* cell_duplicate(n, &c, &cells[0]); lighten(n, &c, 2, y - 1, x - 1); cell_duplicate(n, &c, &cells[1]); @@ -124,6 +120,7 @@ lightup_surrounding_cells(struct ncplane* n, const cell* cells, int y, int x){ lighten(n, &c, 2, y, x - 2); cell_duplicate(n, &c, &cells[11]); lighten(n, &c, 2, y, x + 2); + */ cell_duplicate(n, &c, &cells[12]); lighten(n, &c, 0, y, x); cell_release(n, &c);