

Task
Produce a graphical or ASCII-art representation of a Peano curve of at least order 3.

 
//Abhishek Ghosh, 28th June 2022
 
void Peano(int x, int y, int lg, int i1, int i2) {
 
  if (lg == 1) {
    ellipse(x,y,1,1);
    return;
  }
 
  lg = lg/3;
  Peano(x+(2*i1*lg), y+(2*i1*lg), lg, i1, i2);
  Peano(x+((i1-i2+1)*lg), y+((i1+i2)*lg), lg, i1, 1-i2);
  Peano(x+lg, y+lg, lg, i1, 1-i2);
  Peano(x+((i1+i2)*lg), y+((i1-i2+1)*lg), lg, 1-i1, 1-i2);
  Peano(x+(2*i2*lg), y+(2*(1-i2)*lg), lg, i1, i2);
  Peano(x+((1+i2-i1)*lg), y+((2-i1-i2)*lg), lg, i1, i2);
  Peano(x+(2*(1-i1)*lg), y+(2*(1-i1)*lg), lg, i1, i2);
  Peano(x+((2-i1-i2)*lg), y+((1+i2-i1)*lg), lg, 1-i1, i2);
  Peano(x+(2*(1-i2)*lg), y+(2*i2*lg), lg, 1-i1, i2);
}
 
void setup(){
  size(1000,1000);
  Peano(0, 0, 1000, 0, 0);
}
 