User Tools

Site Tools


tracy444a:sierpinsky_carpet

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tracy444a:sierpinsky_carpet [2010/10/06 19:27]
tracyam0
tracy444a:sierpinsky_carpet [2010/10/06 21:34] (current)
tracyam0
Line 9: Line 9:
 Feder, Jens. Fractals. New York: Plenum Press, 1988. Print. Feder, Jens. Fractals. New York: Plenum Press, 1988. Print.
  
 +----
  
 Also of interest, I discovered [[http://​spanky.triumf.ca/​www/​fractint/​fractint.html|Fractint]]. I'm not entirely sure how to work this program, but it made some pretty pictures for me. Also of interest, I discovered [[http://​spanky.triumf.ca/​www/​fractint/​fractint.html|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:
 +
 +
 +
 +<​html>​
 +
 +<a href="​http://​arthur.sewanee.edu/​tracyam0/​CS444/​Sierpinski/"><​img src="​http://​arthur.sewanee.edu/​tracyam0/​CS444/​Sierpinski.png/"​ alt="​Sierpinski!"​ width="​150"​ height="​150"​ /></​a>​
 +<br>
 +
 +
 +&​nbsp&​nbsp&​nbsp&​nbsp&​nbsp&​nbsp<​a href="​http://​arthur.sewanee.edu/​tracyam0/​CS444/​Sierpinski/">​Sierpinski Carpet!</​a>​
 +</​html>​
 +
 +Here is the Processing code to make the Sierpinski Carpet:
 +
 +<code java>
 +
 +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;
 +  }
 +}
 +
 +
 +</​code>​
 +
tracy444a/sierpinsky_carpet.1286411269.txt.gz ยท Last modified: 2010/10/06 19:27 by tracyam0