summaryrefslogtreecommitdiff
path: root/src/powder.c
diff options
context:
space:
mode:
authorJacob1 <jfu614@gmail.com>2012-03-14 22:49:19 (GMT)
committer Jacob1 <jfu614@gmail.com>2012-03-14 22:49:19 (GMT)
commit1cfcd25c369e8ec4ea66bd2acb3a5368801bf89e (patch)
tree33b0be22a7cc42c9fccf722eb4dbf0d92ccdf5d5 /src/powder.c
parentb765edb981b72fe9b7faf3cceb2b82a17730b488 (diff)
downloadpowder-1cfcd25c369e8ec4ea66bd2acb3a5368801bf89e.zip
powder-1cfcd25c369e8ec4ea66bd2acb3a5368801bf89e.tar.gz
Increase drawing speed
Diffstat (limited to 'src/powder.c')
-rw-r--r--src/powder.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/powder.c b/src/powder.c
index 91a478d..4c3d65d 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -3167,22 +3167,33 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags)
f = 1;
}
else
- for (j=-ry; j<=ry; j++)
- for (i=-rx; i<=rx; i++)
- if (InCurrentBrush(i ,j ,rx ,ry))
- if (create_part_add_props(-2, x+i, y+j, c, rx, ry)==-1)
- f = 1;
+ {
+ int tempy = y, i, j;
+ for (i = x - rx; i <= x; i++) {
+ while (InCurrentBrush(i-x,tempy-y,rx,ry)) {
+ 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;
}
+
int InCurrentBrush(int i, int j, int rx, int ry)
{
switch(CURRENT_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;
case SQUARE_BRUSH:
- return (i*j<=ry*rx);
+ return (abs(i) <= rx && abs(j) <= ry);
break;
case TRI_BRUSH:
return (j <= ry ) && ( j >= (((-2.0*ry)/rx)*i) -ry) && ( j >= (((-2.0*ry)/(-rx))*i)-ry ) ;