diff options
| author | jacksonmj <mj-pt@jacksonmj.co.uk> | 2011-07-13 19:32:10 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-07-24 12:07:15 (GMT) |
| commit | f8d60b14d269f486a11a8f4d0db57791e06a0409 (patch) | |
| tree | b931327d95471a225772fb64021c0ffc6f435f22 /src | |
| parent | c35a8e45ee8c9085dabcc8b530a043940be3b017 (diff) | |
| download | powder-f8d60b14d269f486a11a8f4d0db57791e06a0409.zip powder-f8d60b14d269f486a11a8f4d0db57791e06a0409.tar.gz | |
Avoid division by zero for circle brush
Diffstat (limited to 'src')
| -rw-r--r-- | src/graphics.c | 4 | ||||
| -rw-r--r-- | src/powder.c | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/graphics.c b/src/graphics.c index 1d9438e..f738354 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -4268,7 +4268,9 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry) { for (j=0; j<=ry; j++) for (i=0; i<=rx; i++) - if ((pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1 && ((pow(i+1,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))>1 || (pow(i,2))/(pow(rx,2))+(pow(j+1,2))/(pow(ry,2))>1)) + if (pow(i,2)*pow(ry,2)+pow(j,2)*pow(rx,2)<=pow(rx,2)*pow(ry,2) && + (pow(i+1,2)*pow(ry,2)+pow(j,2)*pow(rx,2)>pow(rx,2)*pow(ry,2) || + pow(i,2)*pow(ry,2)+pow(j+1,2)*pow(rx,2)>pow(rx,2)*pow(ry,2))) { xor_pixel(x+i, y+j, vid); if (j) xor_pixel(x+i, y-j, vid); diff --git a/src/powder.c b/src/powder.c index db65303..8cdd84c 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2794,7 +2794,7 @@ int InCurrentBrush(int i, int j, int rx, int ry) switch(CURRENT_BRUSH) { case CIRCLE_BRUSH: - return ((pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1); + return (pow(i,2)*pow(ry,2)+pow(j,2)*pow(rx,2)<=pow(rx,2)*pow(ry,2)); break; case SQUARE_BRUSH: return (i*j<=ry*rx); |
