Skip to content

Commit

Permalink
Make gdImageRectangle simpler and get rid of dead assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
oerdnj committed May 22, 2013
1 parent 17ce9be commit a3016ad
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2147,17 +2147,16 @@ static void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc)

BGD_DECLARE(void) gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
{
int x1h = x1, x1v = x1, y1h = y1, y1v = y1, x2h = x2, x2v = x2, y2h = y2, y2v = y2;
int thick = im->thick;
int t;

if (x1 == x2 && y1 == y2 && thick == 1) {
gdImageSetPixel(im, x1, y1, color);
return;
}

if (y2 < y1) {
t=y1;
int t;
t = y1;
y1 = y2;
y2 = t;

Expand All @@ -2166,14 +2165,6 @@ BGD_DECLARE(void) gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y
x2 = t;
}

x1h = x1;
x1v = x1;
y1h = y1;
y1v = y1;
x2h = x2;
x2v = x2;
y2h = y2;
y2v = y2;
if (thick > 1) {
int cx, cy, x1ul, y1ul, x2lr, y2lr;
int half = thick >> 1;
Expand Down Expand Up @@ -2217,12 +2208,10 @@ BGD_DECLARE(void) gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y

return;
} else {
y1v = y1h + 1;
y2v = y2h - 1;
gdImageLine(im, x1h, y1h, x2h, y1h, color);
gdImageLine(im, x1h, y2h, x2h, y2h, color);
gdImageLine(im, x1v, y1v, x1v, y2v, color);
gdImageLine(im, x2v, y1v, x2v, y2v, color);
gdImageLine(im, x1, y1, x2, y1, color);
gdImageLine(im, x1, y2, x2, y2, color);
gdImageLine(im, x1, y1 + 1, x1, y2 - 1, color);
gdImageLine(im, x2, y1 + 1, x2, y2 - 1, color);
}
}

Expand Down

0 comments on commit a3016ad

Please sign in to comment.