Sorry it took a little while… Added them now, not entirely sure if the category is right though. Feel free to edit them also!
Interesting tidbit: The “Enhanced loop” works different than the regular one, which I didn’t expect. It only gives the same 3 points for any recursion depth except 0 (which only plots the starting point). I’m not sure why that happens.
/** Sierpinski test 3 c
All paths method (using recursion)
2020.09.05 Improved with Crisir's method of not using a temp PVector
2020.08.31 Improved with Crisir's method of only displaying at the last recursion depth
2020.08.29 raron
*/
PVector [] coord = {new PVector(0, 0), new PVector(150, 300), new PVector(300, 0)};
void setup()
{
size(400,400);
background(32);
sierpinski(new PVector(150,150), 8);
noLoop();
}
void sierpinski(PVector cPoint, int cDepth)
{
if (cDepth == 0) {
set(50+int(cPoint.x), (height-50)-int(cPoint.y), color(192));
return;
}
for (int v=0; v<3; v++) {
sierpinski(new PVector((cPoint.x+coord[v].x)/2, (cPoint.y+coord[v].y)/2), cDepth-1);
}
// "Enhanced loop" doesn't work!
/**
for (PVector sVertice : coord) {
sierpinski(new PVector(cPoint.x+sVertice.x/2, cPoint.y+sVertice.y/2), cDepth-1);
}
*/
}