Fractal zoom animation

Great answer, thanks!

Probably of no use, just to show the idea roughly:

Koch curve by noel modded

Modified your Rosetta page code a bit
int l = 300;
 
void setup() {
  size(400, 400);
  background(0, 0, 255);
  stroke(255);
  // draw from center of screen
  translate(width/2.0, height/2.0);
  // center curve from lower-left corner of base equilateral triangle
  translate(-l/2.0, l*sqrt(3)/6.0);
  for (int i = 1; i <= 3; i++) {
    kcurve(0, l);
    rotate(radians(120));
    translate(-l, 0);
  }
}
 
void kcurve(float x1, float x2) {
  float s = (x2-x1)/3;
  
  float factor = (1-(screenY(x1+1.5*s, s*sqrt(3)/2)/height));
  float minLength = int(pow(factor,1.5)*50.0)+1;
  //println(s, minLength);
  float lineThickness = (factor+.25)*4;
  strokeWeight(lineThickness);

  if (s < minLength) {
    pushMatrix();
    translate(x1, 0);
    line(0, 0, s, 0);
    line(2*s, 0, 3*s, 0);
    translate(s, 0);
    rotate(radians(60));
    line(0, 0, s, 0);
    translate(s, 0);
    rotate(radians(-120));
    line(0, 0, s, 0);
    popMatrix();
    return;
  }
  pushMatrix();
  translate(x1, 0);
  kcurve(0, s);
  kcurve(2*s, 3*s);
  translate(s, 0);
  rotate(radians(60));
  kcurve(0, s);
  translate(s, 0);
  rotate(radians(-120));
  kcurve(0, s);
  popMatrix();
}

It’s a bit exaggerated, and the lower part isn’t scaled up (zoomed in). Not sure how to do it with the zooming version.

1 Like