Increase drawing speed
This commit is contained in:
parent
b765edb981
commit
1cfcd25c36
25
src/powder.c
25
src/powder.c
@ -3167,22 +3167,33 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags)
|
|||||||
f = 1;
|
f = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
for (j=-ry; j<=ry; j++)
|
{
|
||||||
for (i=-rx; i<=rx; i++)
|
int tempy = y, i, j;
|
||||||
if (InCurrentBrush(i ,j ,rx ,ry))
|
for (i = x - rx; i <= x; i++) {
|
||||||
if (create_part_add_props(-2, x+i, y+j, c, rx, ry)==-1)
|
while (InCurrentBrush(i-x,tempy-y,rx,ry)) {
|
||||||
f = 1;
|
tempy = tempy - 1;
|
||||||
|
}
|
||||||
|
tempy = tempy + 1;
|
||||||
|
for (j = tempy; j <= 2 * y - tempy; j++) {
|
||||||
|
if (create_part_add_props(-2, i, j, c, rx, ry)==-1)
|
||||||
|
f = 1;
|
||||||
|
if (create_part_add_props(-2, 2*x-i, j, c, rx, ry)==-1)
|
||||||
|
f = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return !f;
|
return !f;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InCurrentBrush(int i, int j, int rx, int ry)
|
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(ry,2)+pow(j,2)*pow(rx,2)<=pow(rx,2)*pow(ry,2));
|
return (pow((double)i,2)*pow((double)ry,2)+pow((double)j,2)*pow((double)rx,2)<=pow((double)rx,2)*pow((double)ry,2));
|
||||||
break;
|
break;
|
||||||
case SQUARE_BRUSH:
|
case SQUARE_BRUSH:
|
||||||
return (i*j<=ry*rx);
|
return (abs(i) <= rx && abs(j) <= ry);
|
||||||
break;
|
break;
|
||||||
case TRI_BRUSH:
|
case TRI_BRUSH:
|
||||||
return (j <= ry ) && ( j >= (((-2.0*ry)/rx)*i) -ry) && ( j >= (((-2.0*ry)/(-rx))*i)-ry ) ;
|
return (j <= ry ) && ( j >= (((-2.0*ry)/rx)*i) -ry) && ( j >= (((-2.0*ry)/(-rx))*i)-ry ) ;
|
||||||
|
Reference in New Issue
Block a user