| 16 |
|
|
| 17 |
|
#include "color.h" |
| 18 |
|
|
| 19 |
– |
#include "random.h" |
| 20 |
– |
|
| 19 |
|
#ifndef BSD |
| 20 |
|
#define vfork fork |
| 21 |
|
#endif |
| 23 |
|
#define pscan(y) (ourpict+(y)*hresolu) |
| 24 |
|
#define zscan(y) (ourzbuf+(y)*hresolu) |
| 25 |
|
|
| 28 |
– |
#define PMASK 0xfffffff /* probability mask */ |
| 29 |
– |
#define sampval(x) (long)((x)*(PMASK+1)+.5) |
| 30 |
– |
#define samp(p) ((p) > (random()&PMASK)) |
| 31 |
– |
|
| 26 |
|
#define F_FORE 1 /* fill foreground */ |
| 27 |
|
#define F_BACK 2 /* fill background */ |
| 28 |
|
|
| 47 |
|
char *progname; |
| 48 |
|
|
| 49 |
|
int fillo = F_FORE|F_BACK; /* selected fill options */ |
| 50 |
< |
long sampprob = 0; /* sample probability */ |
| 50 |
> |
int fillsamp = 0; /* sample separation (0 == inf) */ |
| 51 |
|
extern int backfill(), rcalfill(); /* fill functions */ |
| 52 |
|
int (*fillfunc)() = backfill; /* selected fill function */ |
| 53 |
|
COLR backcolr = BLKCOLR; /* background color */ |
| 115 |
|
break; |
| 116 |
|
case 's': /* sample */ |
| 117 |
|
check(3,1); |
| 118 |
< |
sampprob = sampval(atof(argv[++i])); |
| 118 |
> |
fillsamp = atoi(argv[++i]); |
| 119 |
|
break; |
| 120 |
|
case 'c': /* color */ |
| 121 |
|
check(3,3); |
| 194 |
|
addpicture(argv[i], argv[i+1]); |
| 195 |
|
/* fill in spaces */ |
| 196 |
|
if (fillo&F_BACK) |
| 197 |
< |
backpicture(fillfunc, sampprob); |
| 197 |
> |
backpicture(fillfunc, fillsamp); |
| 198 |
|
else |
| 199 |
|
fillpicture(fillfunc); |
| 200 |
|
/* close calculation */ |
| 465 |
|
} |
| 466 |
|
|
| 467 |
|
|
| 468 |
< |
backpicture(fill, prob) /* background fill algorithm */ |
| 468 |
> |
backpicture(fill, samp) /* background fill algorithm */ |
| 469 |
|
int (*fill)(); |
| 470 |
< |
long prob; |
| 470 |
> |
int samp; |
| 471 |
|
{ |
| 472 |
|
int *yback, xback; |
| 473 |
|
int y; |
| 518 |
|
xback = x-1; |
| 519 |
|
} |
| 520 |
|
/* |
| 521 |
< |
* Check to see if we have no background for |
| 522 |
< |
* this pixel. If not, or sampling was |
| 523 |
< |
* requested, use the given fill function. |
| 521 |
> |
* If we have no background for this pixel, |
| 522 |
> |
* or if the background is too distant, |
| 523 |
> |
* use the given fill function. |
| 524 |
|
*/ |
| 525 |
< |
if ((xback < 0 && yback[x] < 0) || samp(prob)) { |
| 525 |
> |
if ((xback < 0 && yback[x] < 0) |
| 526 |
> |
|| (samp > 0 |
| 527 |
> |
&& ABS(x-xback) >= samp |
| 528 |
> |
&& ABS(y-yback[y]) >= samp)) { |
| 529 |
|
(*fill)(x,y); |
| 530 |
+ |
if (fill != backfill) { /* reuse */ |
| 531 |
+ |
yback[x] = -2; |
| 532 |
+ |
xback = -2; |
| 533 |
+ |
} |
| 534 |
|
continue; |
| 535 |
|
} |
| 536 |
|
/* |