=category Drawing
=synopsis i_arc_aa(im, 50, 50, 35, 90, 135, &color);
-Antialias fills an arc centered at (x,y) with radius I<rad> covering
+Anti-alias fills an arc centered at (x,y) with radius I<rad> covering
the range of angles in degrees from d1 to d2, with the color.
=cut
=category Drawing
=synopsis i_arc_aa_cfill(im, 50, 50, 35, 90, 135, fill);
-Antialias fills an arc centered at (x,y) with radius I<rad> covering
+Anti-alias fills an arc centered at (x,y) with radius I<rad> covering
the range of angles in degrees from d1 to d2, with the fill object.
=cut
=category Drawing
=synopsis i_circle_aa(im, 50, 50, 45, &color);
-Antialias fills a circle centered at (x,y) for radius I<rad> with
+Anti-alias fills a circle centered at (x,y) for radius I<rad> with
color.
=cut
void
i_box_filled(i_img *im,int x1,int y1,int x2,int y2, const i_color *val) {
- int x,y;
+ i_img_dim x, y, width;
+ i_palidx index;
+
mm_log((1,"i_box_filled(im* 0x%x,x1 %d,y1 %d,x2 %d,y2 %d,val 0x%x)\n",im,x1,y1,x2,y2,val));
- for(x=x1;x<x2+1;x++) for (y=y1;y<y2+1;y++) i_ppix(im,x,y,val);
+
+ if (x1 > x2 || y1 > y2
+ || x2 < 0 || y2 < 0
+ || x1 >= im->xsize || y1 > im->ysize)
+ return;
+
+ if (x1 < 0)
+ x1 = 0;
+ if (x2 >= im->xsize)
+ x2 = im->xsize - 1;
+ if (y1 < 0)
+ y1 = 0;
+ if (y2 >= im->ysize)
+ y2 = im->ysize - 1;
+
+ width = x2 - x1 + 1;
+
+ if (im->type == i_palette_type
+ && i_findcolor(im, val, &index)) {
+ i_palidx *line = mymalloc(sizeof(i_palidx) * width);
+
+ for (x = 0; x < width; ++x)
+ line[x] = index;
+
+ for (y = y1; y <= y2; ++y)
+ i_ppal(im, x1, x2+1, y, line);
+
+ myfree(line);
+ }
+ else {
+ i_color *line = mymalloc(sizeof(i_color) * width);
+
+ for (x = 0; x < width; ++x)
+ line[x] = *val;
+
+ for (y = y1; y <= y2; ++y)
+ i_plin(im, x1, x2+1, y, line);
+
+ myfree(line);
+ }
}
/*
}
/*
-=item i_line(im, x1, y1, x2, y2, val, endp)
+=item i_line(C<im>, C<x1>, C<y1>, C<x2>, C<y2>, C<color>, C<endp>)
=category Drawing
-Draw a line to image using bresenhams linedrawing algorithm
+=for stopwords Bresenham's
+
+Draw a line to image using Bresenham's line drawing algorithm
- im - image to draw to
- x1 - starting x coordinate
- y1 - starting x coordinate
- x2 - starting x coordinate
- y2 - starting x coordinate
- val - color to write to image
- endp - endpoint flag (boolean)
+ im - image to draw to
+ x1 - starting x coordinate
+ y1 - starting x coordinate
+ x2 - starting x coordinate
+ y2 - starting x coordinate
+ color - color to write to image
+ endp - endpoint flag (boolean)
=cut
*/
}
/*
-=item i_line_aa(im, x1, x2, y1, y2, color, endp)
+=item i_line_aa(C<im>, C<x1>, C<x2>, C<y1>, C<y2>, C<color>, C<endp>)
=category Drawing
-Antialias draws a line from (x1,y1) to (x2, y2) in color.
+Anti-alias draws a line from (x1,y1) to (x2, y2) in color.
-The point (x2, y2) is drawn only if endp is set.
+The point (x2, y2) is drawn only if C<endp> is set.
=cut
*/
ltx = i_lspan(im, seedx, seedy, seed, cmpfunc);
rtx = i_rspan(im, seedx, seedy, seed, cmpfunc);
for(tx=ltx; tx<=rtx; tx++) SET(tx, seedy);
+ bxmin = ltx;
+ bxmax = rtx;
ST_PUSH(ltx, rtx, ltx, rtx, seedy+1, 1);
ST_PUSH(ltx, rtx, ltx, rtx, seedy-1, -1);
if ( lx >= 0 && (wasIn = INSIDE(lx, y, seed)) ) {
SET(lx, y);
lx--;
- while(INSIDE(lx, y, seed) && lx > 0) {
+ while(lx >= 0 && INSIDE(lx, y, seed)) {
SET(lx,y);
lx--;
}
}
/*
-=item i_flood_fill(im, seedx, seedy, color)
+=item i_flood_fill(C<im>, C<seedx>, C<seedy>, C<color>)
=category Drawing
=synopsis i_flood_fill(im, 50, 50, &color);
-Flood fills the 4-connected region starting from the point (seedx,
-seedy) with I<color>.
+Flood fills the 4-connected region starting from the point (C<seedx>,
+C<seedy>) with I<color>.
-Returns false if (seedx, seedy) are outside the image.
+Returns false if (C<seedx>, C<seedy>) are outside the image.
=cut
*/
}
/*
-=item i_flood_cfill(im, seedx, seedy, fill)
+=item i_flood_cfill(C<im>, C<seedx>, C<seedy>, C<fill>)
=category Drawing
=synopsis i_flood_cfill(im, 50, 50, fill);
-Flood fills the 4-connected region starting from the point (seedx,
-seedy) with I<fill>.
+Flood fills the 4-connected region starting from the point (C<seedx>,
+C<seedy>) with C<fill>.
-Returns false if (seedx, seedy) are outside the image.
+Returns false if (C<seedx>, C<seedy>) are outside the image.
=cut
*/
}
/*
-=item i_flood_fill_border(im, seedx, seedy, color, border)
+=item i_flood_fill_border(C<im>, C<seedx>, C<seedy>, C<color>, C<border>)
=category Drawing
=synopsis i_flood_fill_border(im, 50, 50, &color, &border);
-Flood fills the 4-connected region starting from the point (seedx,
-seedy) with I<color>, fill stops when the fill reaches a pixels with
-color I<border>.
+Flood fills the 4-connected region starting from the point (C<seedx>,
+C<seedy>) with C<color>, fill stops when the fill reaches a pixels
+with color C<border>.
-Returns false if (seedx, seedy) are outside the image.
+Returns false if (C<seedx>, C<seedy>) are outside the image.
=cut
*/
}
/*
-=item i_flood_cfill_border(im, seedx, seedy, fill, border)
+=item i_flood_cfill_border(C<im>, C<seedx>, C<seedy>, C<fill>, C<border>)
=category Drawing
=synopsis i_flood_cfill_border(im, 50, 50, fill, border);
-Flood fills the 4-connected region starting from the point (seedx,
-seedy) with I<fill>, the fill stops when it reaches pixels of color
-I<border>.
+Flood fills the 4-connected region starting from the point (C<seedx>,
+C<seedy>) with C<fill>, the fill stops when it reaches pixels of color
+C<border>.
-Returns false if (seedx, seedy) are outside the image.
+Returns false if (C<seedx>, C<seedy>) are outside the image.
=cut
*/