FloatImg/funcs/rectangle.c

39 lines
845 B
C
Raw Normal View History

2021-10-18 03:32:53 +11:00
/*
* R E C T A N G L E
* This is an eternal WIP, sorry...
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
2021-10-19 12:56:56 +11:00
#include <string.h>
2021-10-18 03:32:53 +11:00
#include <math.h>
#include "../floatimg.h"
/* --------------------------------------------------------------------- */
int fimg_clear_rectangle(FloatImg *pi, int coo[4])
{
int line, off;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, pi, coo);
#endif
/* please add boudary checks */
for (line=0; line<coo[3]; line++) {
off = (line+coo[1])*pi->width + coo[0];
2021-10-19 12:56:56 +11:00
// fprintf(stderr, "line %3d off %8d\n", line, off);
/* Kaboum ! */
memset(pi->R + off, 0, coo[2]*sizeof(float));
memset(pi->G + off, 0, coo[2]*sizeof(float));
memset(pi->B + off, 0, coo[2]*sizeof(float));
2021-10-18 03:32:53 +11:00
}
return -1;
}
/* --------------------------------------------------------------------- */