Created
February 16, 2018 00:10
-
-
Save shutosg/4752771c595e18850b4eddd875ca4dfc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Menger(PVector centerPosition, float sideWidth) | |
{ | |
rect(centerPosition.x - sideWidth / 6, centerPosition.y - sideWidth / 6, | |
sideWidth/3, sideWidth/3); | |
if(sideWidth < 3) return; | |
for(int i=-1; i<2; i++) | |
{ | |
for(int j=-1; j<2; j++) | |
{ | |
if(i==0 && j==0) continue; | |
Menger( | |
new PVector(centerPosition.x + j * sideWidth / 3, | |
centerPosition.y + i * sideWidth / 3), | |
sideWidth / 3 | |
); | |
} | |
} | |
} | |
void setup() | |
{ | |
size(800, 800); | |
background(0); | |
fill(255); | |
noStroke(); | |
rect(0, 0, width, height); | |
fill(100); | |
Menger(new PVector(width/2, height/2), width); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment