User Tools

Site Tools


tracy444a:plain_version

Plain (Original) Version of Sierpinski Carpet inspired fractal

Fractal!
      Cool Fractal!

Here is the Processing code to make the original cool, Sierpinski inspired fractal:

PImage flower;
float count;
float number;
float num;
float sz;
 
void setup() {
  count=0;
  number=1;
  sz=1;
  num=2;
 
  flower=loadImage("pink_flower.jpg");
  size(flower.width,flower.height);
  background(255);
}
 
void mousePressed() {
  count++;
  number=pow(4,count);
  num=pow(2,count+1);
  sz=pow(.43,count);
  redraw();
}
 
void draw() {
 
 
  imageMode(CENTER);
  int x=1;
  int y=1;
 
 
  for(int i=0; i<number; i++) {
 
    if(x>num) {
      x=1;
      y+=2;
    }
    float r=(x*width)/num;
    float s=y*height/num;
    float u=width*sz;
    float v=height*sz;
 
 
 
    image(flower,r,s,u,v);
 
    x+=2;
  }
}
tracy444a/plain_version.txt · Last modified: 2010/09/22 20:41 by tracyam0