2019-03-03 16:22:55 +01:00
|
|
|
/*
|
|
|
|
testing some random funcs.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
2020-02-29 20:52:06 +01:00
|
|
|
int fimg_test_pattern(FloatImg *fimg, int type, double dval)
|
|
|
|
{
|
|
|
|
int nio;
|
|
|
|
int x, y;
|
2020-02-29 21:34:29 +01:00
|
|
|
float fr, fg, fb, val;
|
2020-02-29 20:52:06 +01:00
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, ">>> %s ( %p %d %g )\n", __func__, fimg, type, dval);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (fimg->type != FIMG_TYPE_RGB) {
|
|
|
|
fprintf(stderr, "%s need an rgb pic\n", __func__);
|
|
|
|
return -6;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* rampe de primaires dans le quart du haut */
|
2020-02-29 21:34:29 +01:00
|
|
|
val = (float)dval;
|
2020-02-29 20:52:06 +01:00
|
|
|
for (x=0; x<fimg->width; x++) {
|
|
|
|
nio = x / (fimg->width / 8);
|
|
|
|
switch(nio) {
|
2020-02-29 21:34:29 +01:00
|
|
|
case 0: fr = 0.0, fg = 0.0, fb = 0.0; break;
|
|
|
|
case 1: fr = val, fg = 0.0, fb = 0.0; break;
|
|
|
|
case 2: fr = 0.0, fg = val, fb = 0.0; break;
|
|
|
|
case 3: fr = val, fg = val, fb = 0.0; break;
|
|
|
|
case 4: fr = 0.0, fg = 0.0, fb = val; break;
|
|
|
|
case 5: fr = val, fg = 0.0, fb = val; break;
|
|
|
|
case 6: fr = 0.0, fg = val, fb = val; break;
|
|
|
|
case 7: fr = val, fg = val, fb = val; break;
|
2020-02-29 20:52:06 +01:00
|
|
|
default:
|
2020-02-29 21:34:29 +01:00
|
|
|
abort(); break;
|
2020-02-29 20:52:06 +01:00
|
|
|
}
|
|
|
|
for (y=0; y<fimg->height/4; y++)
|
|
|
|
fimg_plot_rgb(fimg, x, y, fr, fg, fb);
|
|
|
|
}
|
|
|
|
|
2020-03-17 09:29:20 +01:00
|
|
|
|
|
|
|
|
2020-02-29 21:34:29 +01:00
|
|
|
return 0;
|
2020-02-29 20:52:06 +01:00
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
2019-03-03 16:22:55 +01:00
|
|
|
int fimg_draw_something(FloatImg *fimg)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
float fx, fy;
|
|
|
|
|
|
|
|
#define K (3.14159*13.456)
|
|
|
|
#define M 100.0
|
|
|
|
|
|
|
|
for (x=0; x<fimg->width; x++) {
|
|
|
|
fimg_plot_rgb(fimg, x, 0,
|
|
|
|
(float)x,
|
|
|
|
(float)x + 5.678,
|
|
|
|
(float)x * 1.33333);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (y=1; y<fimg->height; y++) {
|
|
|
|
fy = (float)y / (float)fimg->height;
|
|
|
|
for (x=0; x<fimg->width; x++) {
|
|
|
|
fx = (float)x / (float)fimg->width;
|
|
|
|
fimg_plot_rgb(fimg, x, y,
|
|
|
|
M*(cos(fx*K)+1.2),
|
2019-12-31 12:02:37 +01:00
|
|
|
M*(sin(fy*K)+1.4),
|
|
|
|
M*(cos(fx*fy)+1.6));
|
2019-03-03 16:22:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int fimg_multirandom(FloatImg *fimg)
|
|
|
|
{
|
|
|
|
int foo, x, y;
|
|
|
|
|
|
|
|
#define RI ( (rand()/7) + (rand()/9) )
|
|
|
|
#define RD ( (drand48()/7) + (drand48()/7) )
|
|
|
|
|
|
|
|
for (foo=0; foo<100000000; foo++)
|
|
|
|
{
|
|
|
|
x = RI % fimg->width;
|
|
|
|
y = RI % fimg->height;
|
|
|
|
fimg_add_rgb(fimg, x, y, RD, RD, RD);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|