first shoot
This commit is contained in:
57
funcs/misc-plots.c
Normal file
57
funcs/misc-plots.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
testing some random funcs.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
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),
|
||||
M*(cos(fy*K)+1.2),
|
||||
M*(cos(fx*fy)+1.2));
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
Reference in New Issue
Block a user