large cursor size doesn't cause any lag at all

This commit is contained in:
Jacob1 2011-11-23 10:35:54 -05:00
parent dea920680b
commit 7742586639

View File

@ -3631,46 +3631,39 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry)
if (t<PT_NUM||(t&0xFF)==PT_LIFE||t==SPC_AIR||t==SPC_HEAT||t==SPC_COOL||t==SPC_VACUUM||t==SPC_WIND||t==SPC_PGRV||t==SPC_NGRV) if (t<PT_NUM||(t&0xFF)==PT_LIFE||t==SPC_AIR||t==SPC_HEAT||t==SPC_COOL||t==SPC_VACUUM||t==SPC_WIND||t==SPC_PGRV||t==SPC_NGRV)
{ {
if (rx<=0) if (rx<=0)
xor_pixel(x, y, vid); for (j = y - ry; j <= y + ry; j++)
xor_pixel(x, j, vid);
else if (ry<=0) else if (ry<=0)
xor_pixel(x, y, vid); for (i = x - rx; i <= x + rx; i++)
if (rx+ry<=0) xor_pixel(i, y, vid);
xor_pixel(x, y, vid); else
else if (CURRENT_BRUSH==SQUARE_BRUSH)
{ {
for (j=0; j<=ry; j++) int tempy = y, i, j, jmax, oldy;
for (i=0; i<=rx; i++) if (CURRENT_BRUSH == TRI_BRUSH)
if (i*j<=ry*rx && ((i+1)>rx || (j+1)>ry)) tempy = y + ry;
{ for (i = x - rx; i <= x; i++) {
xor_pixel(x+i, y+j, vid); oldy = tempy;
xor_pixel(x-i, y-j, vid); while (InCurrentBrush(i-x,tempy-y,rx,ry))
if (i&&j)xor_pixel(x+i, y-j, vid); tempy = tempy - 1;
if (i&&j)xor_pixel(x-i, y+j, vid); tempy = tempy + 1;
} jmax = 2*y - tempy;
} if (oldy != tempy && CURRENT_BRUSH != SQUARE_BRUSH)
else if (CURRENT_BRUSH==CIRCLE_BRUSH) oldy--;
{ if (CURRENT_BRUSH == TRI_BRUSH)
for (j=0; j<=ry; j++) oldy = tempy;
for (i=0; i<=rx; i++) for (j = tempy; j <= oldy; j++) {
if (pow(i,2)*pow(ry,2)+pow(j,2)*pow(rx,2)<=pow(rx,2)*pow(ry,2) && int i2 = 2*x-i, j2 = 2*y-j;
(pow(i+1,2)*pow(ry,2)+pow(j,2)*pow(rx,2)>pow(rx,2)*pow(ry,2) || if (CURRENT_BRUSH == TRI_BRUSH)
pow(i,2)*pow(ry,2)+pow(j+1,2)*pow(rx,2)>pow(rx,2)*pow(ry,2))) j2 = y+ry;
{ xor_pixel(i, j, vid);
xor_pixel(x+i, y+j, vid); if (i2 != i)
if (j) xor_pixel(x+i, y-j, vid); xor_pixel(i2, j, vid);
if (i) xor_pixel(x-i, y+j, vid); if (j2 != j)
if (i&&j) xor_pixel(x-i, y-j, vid); xor_pixel(i, j2, vid);
} if (i2 != i && j2 != j)
} xor_pixel(i2, j2, vid);
else if (CURRENT_BRUSH==TRI_BRUSH) }
{ }
for (j=-ry; j<=ry; j++)
for (i=-rx; i<=0; i++)
if ((j <= ry ) && ( j >= (((-2.0*ry)/(rx))*i)-ry ) && (j+1>ry || ( j-1 < (((-2.0*ry)/(rx))*i)-ry )) )
{
xor_pixel(x+i, y+j, vid);
if (i) xor_pixel(x-i, y+j, vid);
}
} }
} }
else //wall cursor else //wall cursor