From 07dde749ed48d5f009ada08d1631493237eb26e2 Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 12 May 2021 12:04:55 +0200 Subject: [PATCH] new pattern (mircol_1) in mkfimg --- floatimg.h | 3 ++- funcs/misc-plots.c | 18 ++++++++++++++++++ tools/mkfimg.c | 11 ++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/floatimg.h b/floatimg.h index d1965083..57a8dc73 100644 --- a/floatimg.h +++ b/floatimg.h @@ -4,7 +4,7 @@ * http://la.buvette.org/photos/cumul */ -#define FIMG_VERSION 145 +#define FIMG_VERSION 147 /* * 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_draw_something(FloatImg *fimg); +int fimg_mircol_1(FloatImg *dst, float mval); int fimg_multirandom(FloatImg *fimg, long nbpass); /* file is 'funcs/utils.c' */ diff --git a/funcs/misc-plots.c b/funcs/misc-plots.c index 32c095b5..3570b4f5 100644 --- a/funcs/misc-plots.c +++ b/funcs/misc-plots.c @@ -86,6 +86,24 @@ for (y=1; yheight; y++) { return 0; } /* --------------------------------------------------------------------- */ +int fimg_mircol_1(FloatImg *dst, float mval) +{ +int x, y; +float fx, fy, rgb[3]; + +for (y=0; yheight; y++) { + fy = (float)y / (float)dst->height; + for (x=0; xwidth; 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 foo, x, y; diff --git a/tools/mkfimg.c b/tools/mkfimg.c index e418fcdd..2f6cc574 100644 --- a/tools/mkfimg.c +++ b/tools/mkfimg.c @@ -20,6 +20,7 @@ int verbosity; #define T_HDEG_A 4 #define T_VDEG_A 5 #define T_TPAT0 6 +#define T_MIRCOL1 7 typedef struct { int code; @@ -34,6 +35,7 @@ Type types[] = { { T_HDEG_A, "hdeg" }, { T_VDEG_A, "vdeg" }, { T_TPAT0, "tpat0" }, + { T_MIRCOL1, "mircol1" }, { 0, NULL } }; @@ -58,7 +60,7 @@ return -1; /* --------------------------------------------------------------------- */ static void help(int lj) { -int foo; +int foo, cc; puts("Usage:\tmkfimg [options] quux.fimg width height"); @@ -122,13 +124,15 @@ switch (nbargs) { height = atoi(argv[optind+2]); break; default: - fprintf(stderr, "%s need filename, width & height\n", argv[0]); + fprintf(stderr, "%s need filename, width & height\n", + argv[0]); exit(1); } 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", fname, width, height, type); @@ -149,6 +153,7 @@ switch(type) { case T_HDEG_A: fimg_hdeg_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_MIRCOL1: fimg_mircol_1(&fimg, fvalue); break; case -1: exit(1); }