mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 09:39:03 -04:00
demo: reject multiplier <= 0
This commit is contained in:
parent
4fca9425d9
commit
f8c870bb76
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user