1 post tagged “processing.js”
I tried John Resig's processing.js, which is processing implementation on javascript.
This is a program to draw the Sierpinski carpet fractal.
var max = 3;
void draw_iter(x,y,w,h,n){
var wn = w/3;
var hn = h/3;
pushMatrix();
translate(x,y);
rect(wn,hn,wn,hn);
popMatrix();
if( max <= ++n ) return;
for( var i = 0; i < 9; i++ ){
if( i == 4 ) continue;
draw_iter( x+wn*(i%3), y+hn*Math.floor(i/3), wn, hn, n );
}
}
void setup(){
size(144,144);
background(120);
stroke(255);
draw_iter(0,0,144,144,0);
}
As you see, it's quite simple. You can see the output picture of this program in my another blog