fps performance when drawing many lines

Hello. I am animating a lot of lines to an analysis of music frequencies. The lines should rotate from left to line more if its corresponding frequency has a lot of amplitude. I would like to get 60 fps, but I can only get around 15 fps.

I am drawing 14310 lines of 9 pixels length with smooth(2); on. I have found that the mail culprit is this anti-aliasing, because if I do noSmooth(); I get around 54 fps, which is closer to what I want. But I am not yet sure if I like to non-anti-aliased lines better then the other, so I'd like to be able to do both with proper performance.
Also if I just draw 4000 lines, I get about 47 fps.
So I figure the problem is the high amount of lines combined with the anti-aliasing.

Does anyone have any advice on how to increase my fps with the same amount of smooth lines?

I am using Processing 3.1.1 on OS X 10.11.5. My simplified code is below.

// set up classes for a font and the lines
PFont font;
Line[] lines;

// setting variables
int bands = 80;
float yAmount = 48;

// initiate global variables
float xAmount = bands - 1;
int count = int(xAmount * yAmount);

void setup()
  // set initial settings

  // initiate line objects
  lines = new Line[count];

  int index = 0;
  for (int x = 0; x < xAmount; x++){
    for (int y = 0; y < yAmount; y++){
      lines[index++] = new Line(x*10 + 10, y*15 + 9);

  // create font
  font = createFont("Arial Bold", 32);

void draw()

  for(int z = 0; z < count; z++)

  // something to show framerate

class Line
  int x;
  int y;

  Line(int xTemp, int yTemp)
    x = xTemp;
    y = yTemp;

  void display(){


  • Answer ✓

    Have you tried FX2D renderer out? :-?

  • I haven't. Before I googled FX2D renderer I didn't know you could use different renderers. I am now using the P2D renderer with fullScreen(P2D); and it gives me 60fps consistently.

    Thank you for pointing me in the right direction!

Sign In or Register to comment.