processing4 icon indicating copy to clipboard operation
processing4 copied to clipboard

performance breakpoint with strokeWeight >= 2.0 in P2D

Open clankill3r opened this issue 1 year ago • 0 comments

The difference between scale(1.999999); and scale(2); in the sketch below is that with scale(2); there is a frameRate drop of around 50fps!

Screenshot 2024-05-19 at 10 49 56 Screenshot 2024-05-19 at 10 50 20
  • This is only in P2D (to be extra clear, so not in P3D!).
  • It breaks with all values that are bigger or equal to 2.

void setup() {
  size(600, 600, P2D);
}

void draw() {
  background(0);
  
  pushMatrix();
  //scale(1.999999);
  scale(2);
  draw_recursive(50, 50, width-50, height-50, 0, 7);
  popMatrix();

  fill(255);
  text(""+(int)frameRate, 10, 14);
}


void draw_recursive(float x1, float y1, float x2, float y2, int level, int max_level) {

  if (level < max_level) {
    float cx = x1 + (x2 - x1) / 2;
    float cy = y1 + (y2 - y1) / 2;
    draw_recursive(x1, y1, cx, cy, level+1, max_level);
    draw_recursive(cx, y1, x2, cy, level+1, max_level);
    draw_recursive(x1, cy, cx, y2, level+1, max_level);
    draw_recursive(cx, cy, x2, y2, level+1, max_level);
  } else {
    fill(255, 255, 0);
    stroke(0);
    strokeWeight(1);
    rectMode(CORNERS);
    rect(x1, y1, x2, y2);
  }
}

clankill3r avatar May 19 '24 09:05 clankill3r