It is far from an efficient solution but here it is! It is quite short (altho I haven’t seen a standard solution for it)
ArrayList<String> path = new ArrayList<String>();
int it = 0, maxIt = 10,rep=0;
float cx = 300, cy = 550,x,y,x2,y2, l = 50, ld = 0.9,rot=-PI/2,spin = PI/6;
void setup() {
size(600,600);
for(int i = 0; i < pow(2,maxIt); i++) {
String a = loadZeros(int(binary(i)),maxIt);
path.add(a);
}
background(0);
stroke(255);
strokeWeight(8);
line(cx,cy,cx,cy-l);
}
void draw() {
String load = path.get(rep);
float crot = rot, cl = l, x = cx, y = cy,x2=x,y2=y;
strokeWeight(8);
for(int i = 0; i < maxIt; i++) {
strokeWeight(8/pow(2,i));
x+=cos(crot)*cl;
y+=sin(crot)*cl;
cl*=ld;
crot+=spin*((int(load.charAt(i))*2-1));
line(x,y,x2,y2);
x2 = x;
y2 = y;
}
rep++;
if(rep == pow(2,maxIt)) {
noLoop();
}
}
String loadZeros(int number, int len) {
if((number+"").length() < len) {
String prefix = "";
for(int i = 0; i < len-(number+"").length(); i++) {
prefix += "0";
}
return(prefix + number);
} else {
return(number+"");
}
}
it takes one path at a time, until the end. There is a bug for maxIt (erations) > 10 which I will fix in the near future! Enjoy!