from visual import * from visual.graph import * from random import * gd=gdisplay(xmin=0,xmax=1.0,ymin=0,ymax=1.0, title="Sierpinski triangle", height=600,width=600,x=0,y=200, foreground=color.black, background=color.white) xplot=gdots(color=color.blue) x=0.0 y=0.0 K=3.0 a= arange(K) b= arange(K) c= arange(K) d= arange(K) e= arange(K) f= arange(K) a[0]=0.5 b[0]=0.0 c[0]=0.0 d[0]=0.5 e[0]=0.0 f[0]=0.0 a[1]=0.5 b[1]=0.0 c[1]=0.0 d[1]=0.5 e[1]=0.5 f[1]=0.0 a[2]=0.5 b[2]=0.0 c[2]=0.0 d[2]=0.5 e[2]=0.25 f[2]=0.5 xplot.plot(pos=(x,y)) while(1): rate(500) dum=randint(0,2) x=a[dum]*x+b[dum]*y+e[dum] y=c[dum]*x+d[dum]*y+f[dum] xplot.plot(pos=(x,y))