benfry / processing4

Processing 4.x releases for Java 17
https://processing.org
Other
1.34k stars 239 forks source link

performance breakpoint with strokeWeight >= 2.0 in P2D #837

Open clankill3r opened 4 months ago

clankill3r commented 4 months ago

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

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