Avoid division by zero for circle brush

This commit is contained in:
jacksonmj 2011-07-14 03:32:10 +08:00 committed by Simon Robertshaw
parent c35a8e45ee
commit f8d60b14d2
2 changed files with 4 additions and 2 deletions

View File

@ -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 (j=0; j<=ry; j++)
for (i=0; i<=rx; i++) 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); xor_pixel(x+i, y+j, vid);
if (j) xor_pixel(x+i, y-j, vid); if (j) xor_pixel(x+i, y-j, vid);

View File

@ -2794,7 +2794,7 @@ int InCurrentBrush(int i, int j, int rx, int ry)
switch(CURRENT_BRUSH) switch(CURRENT_BRUSH)
{ {
case CIRCLE_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; break;
case SQUARE_BRUSH: case SQUARE_BRUSH:
return (i*j<=ry*rx); return (i*j<=ry*rx);