Spde → Sierpinski

This Sierpinski Gasket was contributed by EPFL:

For those of you who are mathematically minded or interested in self similar systems and fractals, Anthony Bagwell has provided us with the following code examples. The first is a concise way to create a representation of the popular Sierpinski gasket.

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

val d= 200
size(400, 400)
background(0, 10, 20)
var a=List(List(d/2,0,255,0,0),List(d,d,0,255,0),List(0,d,0,0,255))
var p=List(d,0,255,0,0)
def draw() {
  for(i<-1 to 10) {
    p=p zip a.random map{case (x,y)=>x/2+y}
    stroke(p(2),p(3),p(4))
    point(p(0), p(1))
  }
}

See More Examples