new pattern (mircol_1) in mkfimg

This commit is contained in:
tth 2021-05-12 12:04:55 +02:00
parent 4a52c16e40
commit 07dde749ed
3 changed files with 28 additions and 4 deletions

View File

@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul * http://la.buvette.org/photos/cumul
*/ */
#define FIMG_VERSION 145 #define FIMG_VERSION 147
/* /*
* in memory descriptor * in memory descriptor
@ -218,6 +218,7 @@ int fimg_save_as_bmp(FloatImg *src, char *outname, int flags);
int fimg_test_pattern(FloatImg *fimg, int type, double dval); int fimg_test_pattern(FloatImg *fimg, int type, double dval);
int fimg_draw_something(FloatImg *fimg); int fimg_draw_something(FloatImg *fimg);
int fimg_mircol_1(FloatImg *dst, float mval);
int fimg_multirandom(FloatImg *fimg, long nbpass); int fimg_multirandom(FloatImg *fimg, long nbpass);
/* file is 'funcs/utils.c' */ /* file is 'funcs/utils.c' */

View File

@ -86,6 +86,24 @@ for (y=1; y<fimg->height; y++) {
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int fimg_mircol_1(FloatImg *dst, float mval)
{
int x, y;
float fx, fy, rgb[3];
for (y=0; y<dst->height; y++) {
fy = (float)y / (float)dst->height;
for (x=0; x<dst->width; x++) {
fx = (float)x / (float)dst->width;
rgb[0] = mval * fx;
rgb[1] = mval * ((fx+fy)/2.0);
rgb[2] = mval * fy;
fimg_put_rgb(dst, x, y, rgb);
}
}
return -1;
}
/* --------------------------------------------------------------------- */
int fimg_multirandom(FloatImg *fimg, long nbpass) int fimg_multirandom(FloatImg *fimg, long nbpass)
{ {
int foo, x, y; int foo, x, y;

View File

@ -20,6 +20,7 @@ int verbosity;
#define T_HDEG_A 4 #define T_HDEG_A 4
#define T_VDEG_A 5 #define T_VDEG_A 5
#define T_TPAT0 6 #define T_TPAT0 6
#define T_MIRCOL1 7
typedef struct { typedef struct {
int code; int code;
@ -34,6 +35,7 @@ Type types[] = {
{ T_HDEG_A, "hdeg" }, { T_HDEG_A, "hdeg" },
{ T_VDEG_A, "vdeg" }, { T_VDEG_A, "vdeg" },
{ T_TPAT0, "tpat0" }, { T_TPAT0, "tpat0" },
{ T_MIRCOL1, "mircol1" },
{ 0, NULL } { 0, NULL }
}; };
@ -58,7 +60,7 @@ return -1;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static void help(int lj) static void help(int lj)
{ {
int foo; int foo, cc;
puts("Usage:\tmkfimg [options] quux.fimg width height"); puts("Usage:\tmkfimg [options] quux.fimg width height");
@ -122,13 +124,15 @@ switch (nbargs) {
height = atoi(argv[optind+2]); height = atoi(argv[optind+2]);
break; break;
default: default:
fprintf(stderr, "%s need filename, width & height\n", argv[0]); fprintf(stderr, "%s need filename, width & height\n",
argv[0]);
exit(1); exit(1);
} }
fname = argv[optind]; fname = argv[optind];
if (verbosity>1) fprintf(stderr, "*** mkfimg *** %s %s\n", __DATE__, __TIME__); if (verbosity>1) fprintf(stderr, "*** mkfimg *** %s %s\n",
__DATE__, __TIME__);
if (verbosity) fprintf(stderr, "making '%s' %dx%d, type %d\n", if (verbosity) fprintf(stderr, "making '%s' %dx%d, type %d\n",
fname, width, height, type); fname, width, height, type);
@ -149,6 +153,7 @@ switch(type) {
case T_HDEG_A: fimg_hdeg_a(&fimg, 1.0); break; case T_HDEG_A: fimg_hdeg_a(&fimg, 1.0); break;
case T_VDEG_A: fimg_vdeg_a(&fimg, 1.0); break; case T_VDEG_A: fimg_vdeg_a(&fimg, 1.0); break;
case T_TPAT0: fimg_test_pattern(&fimg, 0, fvalue); break; case T_TPAT0: fimg_test_pattern(&fimg, 0, fvalue); break;
case T_MIRCOL1: fimg_mircol_1(&fimg, fvalue); break;
case -1: exit(1); case -1: exit(1);
} }