# DokuWiki

### Site Tools

tracy444a:sierpinsky_carpet

# Sierpinsky Carpet

According to Mandelbrot, “A fractal is a shape made of parts similar to the whole in some way.” By, this definition, my creation is sort of a fractal. It is created by layering smaller and smaller rectangles. The colors and patterning of the rectangles creates some interesting patterns in the result. However, the individual flower pattern of each rectangle is lost in the final product. It only serves to add interesting coloring patterns. The Sierpinski Carpet which inspired my designed is actually the reverse of my project. Rather than adding rectangles, the Sierpinski Carpet is designed by taking them away. More specifically, the Sierpinski carpet is created by taking a square, dividing it into nine equal squares and removing the center. Then each remaing square is treated the same way, so that smaller squares are continually being removed. The remnant of the original square remaining after this process has been repeated an infinite number of times is the Sierpinski carpet. Sierpinski created his carpet in 1916.

Citations

Mandelbrot, Benolit B. Fractal Geometry of Nature. New York: W.H. Freeman and Company, 1983. Print.

Feder, Jens. Fractals. New York: Plenum Press, 1988. Print.

Also of interest, I discovered Fractint. I'm not entirely sure how to work this program, but it made some pretty pictures for me.

Here is my homemade version of a Sierpinski Carpet:

Here is the Processing code to make the Sierpinski Carpet:

```float count;
float number;
float num;
float sz;

void setup() {
count=0;
number=1;
sz=1;
num=2;
noStroke();

size(500,500);
background(0);
}

void mousePressed() {
count++;
number=pow(9,count);
num=pow(3,count)*2;
sz=pow(.33,count);
redraw();
}

void draw() {

rectMode(CENTER);

int x=3;
int y=3;

for(int i=0; i<number; i++) {

if(x>num) {
x=3;
y+=6;
}
float r=(x*width)/num;
float s=y*height/num;
float u=width*sz;
float v=height*sz;
rect(r,s,u,v);

x+=6;
}
}``` 