21 lines
461 B
Plaintext
21 lines
461 B
Plaintext
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);
|
|
}
|
|
}
|