#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# Fix slow frame rate when drawing multiple quads?

edited March 2014

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)
{
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;

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:  Tagged:

• 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

``````// forum.processing.org/two/discussion/3974/

final FloatList dataList = new FloatList();

void setup() {
size(600, 600, JAVA2D);
noLoop();
smooth(4);

background(0300);
strokeWeight(2);

for (int i = 0; i++ != 45; dataList.append(random(height>>1)));

drawAniWedge(dataList, 180, 90, #0000FF, #FF0000);
}

void drawAniWedge(FloatList dl, float ani, float rot,
color ink, color border) {
fill(ink);
stroke(border);

final int len = dl.size();
final float inc = (len - 1) / ani;
final float cx = width>>1, cy = height>>1;

int i = 0;
float datum = dl.get(i);
float ang = TAU - rot;

float x = cx + cos(ang)*datum;
float y = cy + sin(ang)*datum;

while (++i != len) {
datum = dl.get(i);