|
|
|
@ -31,21 +31,19 @@ int yield_demo(struct notcurses* nc){
|
|
|
|
|
int vy, vx, vscaley, vscalex;
|
|
|
|
|
ncvisual_geom(nc, wmv, vopts.blitter, &vy, &vx, &vscaley, &vscalex);
|
|
|
|
|
struct timespec scaled;
|
|
|
|
|
int threshold_painted = vy * vx * 10 / 9;
|
|
|
|
|
const int ITER = 128;
|
|
|
|
|
timespec_div(&demodelay, ITER, &scaled);
|
|
|
|
|
int threshold_painted = (vy * vscaley) * (vx * vscalex) / 2;
|
|
|
|
|
timespec_div(&demodelay, 128, &scaled);
|
|
|
|
|
int tfilled = 0;
|
|
|
|
|
for(int i = 0 ; i < ITER ; ++i){
|
|
|
|
|
while(tfilled < threshold_painted){
|
|
|
|
|
int pfilled;
|
|
|
|
|
do{
|
|
|
|
|
int x = random() % (vx);
|
|
|
|
|
int y = random() % (vy);
|
|
|
|
|
uint32_t pixel = 0;
|
|
|
|
|
ncvisual_at_yx(wmv, y, x, &pixel);
|
|
|
|
|
uint32_t channel = 0;
|
|
|
|
|
channel_set_rgb(&channel, 0x80, channel_g(pixel), channel_b(pixel));
|
|
|
|
|
//fprintf(stderr, "POLY: %d/%d\n", y, x);
|
|
|
|
|
pfilled = ncvisual_polyfill_yx(wmv, y, x, channel);
|
|
|
|
|
uint32_t newpixel = 0;
|
|
|
|
|
pixel_set_rgb(&newpixel, 0xff, channel_g(pixel), channel_b(pixel));
|
|
|
|
|
pfilled = ncvisual_polyfill_yx(wmv, y, x, newpixel);
|
|
|
|
|
if(pfilled < 0){
|
|
|
|
|
ncvisual_destroy(wmv);
|
|
|
|
|
return -1;
|
|
|
|
@ -58,9 +56,6 @@ int yield_demo(struct notcurses* nc){
|
|
|
|
|
}
|
|
|
|
|
DEMO_RENDER(nc);
|
|
|
|
|
demo_nanosleep(nc, &scaled);
|
|
|
|
|
if(tfilled >= threshold_painted){
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ncvisual_destroy(wmv);
|
|
|
|
|