2020-11-02 11:25:00 +11:00
|
|
|
/*
|
|
|
|
* SPECIAL EFFECTS
|
|
|
|
*
|
|
|
|
* Du code bien cracra / tTh / Tetalab
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
|
|
|
|
#include <floatimg.h>
|
|
|
|
|
|
|
|
#include "fonctions.h"
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------- */
|
|
|
|
/* global vars from main
|
|
|
|
*/
|
2020-11-03 00:51:48 +11:00
|
|
|
extern int verbosity;
|
2020-11-02 11:25:00 +11:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------- */
|
|
|
|
|
2020-11-03 00:51:48 +11:00
|
|
|
/* -------------------------------------------------------------- */
|
|
|
|
int brotche_rand48_a(FloatImg *fimg, float ratio, float mval)
|
2020-11-02 11:25:00 +11:00
|
|
|
{
|
|
|
|
int nbpix, todo, foo;
|
|
|
|
int x, y;
|
|
|
|
float fval;
|
|
|
|
|
|
|
|
nbpix = fimg->width * fimg->height;
|
|
|
|
todo = (int)((float)nbpix * ratio);
|
2020-11-03 00:51:48 +11:00
|
|
|
if (verbosity > 1) {
|
|
|
|
fprintf(stderr, "%s: ratio %f nbpix %d todo %d\n", __func__,
|
|
|
|
ratio, nbpix, todo);
|
|
|
|
}
|
2020-11-02 11:25:00 +11:00
|
|
|
|
|
|
|
for (foo=0; foo<todo; foo++)
|
|
|
|
{
|
|
|
|
fval = (float)drand48() * mval;
|
|
|
|
x = rand() % fimg->width;
|
|
|
|
y = rand() % fimg->height;
|
|
|
|
fimg_plot_rgb(fimg, x, y, fval, fval, fval);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* -------------------------------------------------------------- */
|
|
|
|
int brotche_rand48_b(FloatImg *fimg, float ratio, float mval)
|
|
|
|
{
|
|
|
|
int nbpix, todo, foo;
|
|
|
|
int x, y;
|
|
|
|
float fval;
|
|
|
|
|
|
|
|
nbpix = fimg->width * fimg->height;
|
|
|
|
todo = (int)((float)nbpix * ratio);
|
|
|
|
if (verbosity > 1) {
|
2020-11-03 00:51:48 +11:00
|
|
|
fprintf(stderr, "%s: ratio %f nbpix %d todo %d\n", __func__,
|
2020-11-02 11:25:00 +11:00
|
|
|
ratio, nbpix, todo);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (foo=0; foo<todo; foo++)
|
|
|
|
{
|
|
|
|
fval = (float)drand48() * mval;
|
|
|
|
x = 1 + (rand() % (fimg->width-2));
|
|
|
|
y = rand() % fimg->height;
|
|
|
|
fimg_plot_rgb(fimg, x-1, y, fval, 0.0, 0.0);
|
|
|
|
fimg_plot_rgb(fimg, x , y, 0.0, 0.0, fval);
|
|
|
|
fimg_plot_rgb(fimg, x+1, y, 0.0, fval, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* -------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|