We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm drawing a section of a radial graph with quads and animating the "opening" of the arc. Each arc contains a fair amount of quads being drawn to the screen and consequentially the frame rate is dropping substantially. Any suggestions to keep the frame rate from dropping so dramatically?
Here is the code that draws the arc. The method is being called from the draw() so that I can animate the arc on demand.
float angle;
float x;
float y;
public void drawAniWedge(float ani)
{
angle = radians(360)-rotation;
x = width/2 + cos(angle) * dataList.get(0);
y = height/2 + sin(angle) * dataList.get(0);
for (int i = 1; i < dataList.size(); i++)
{
float dataLength = dataList.size()-1;
float increment = dataLength/ani;
angle = radians(i/increment)-rotation;
newX = width/2 + cos(angle) * dataList.get(i);
newY = height/2 + sin(angle) * dataList.get(i);
fill(fill);
stroke(line);
quad(width/2, height/2, width/2, height/2, x, y, newX, newY);
x = newX;
y = newY;
}
}
Here is what I am drawing:
Answers
Random thoughts: you can put the first two lines of the loop outside of the loop. Same for fill and stroke calls apparently constant through the loop.
But I doubt you will get a big speed boost from these changes. That's probably quad() which is slow. BTW, why not use triangle() there?
My apparently failed attempt on optimizing your function: :-S
@PhiLho I don't know why I didn't think to use triangle()! Fixed that and took those elements out of the loop. Thanks for the advice.
@GoToLoop thanks for having a go at it!