# zen eye candy # note: despite man page, sleep supports times at least # down to 10 ms (not 1 s) bdrun<-function(ilp=1) { thename<-"calming" theline<-"Zzz" thenwas<-Sys.time() par(bg='black') #cat(thenwas) for (iloop in 1:ilp) { #thetime<-as.numeric(format(Sys.time(),"%OS")) #like this: nowis<-Sys.time() #cat(nowis,'\n') #cat(difftime(nowis,thenwas)) #bd() needs interesting integer to set the seed theline=paste(theline,"...Zzzz",sep="") thetime<-1e5*as.numeric(difftime(nowis,thenwas)) slowbd(name=thename, birthday=thetime,theline=theline) system('sleep 1') thenwas<-nowis } #back to normal par(bg='white') } # #modified bd to have better title and to 'grow' the picture # added 'slptm' to adjust speed slowbd<-function(name="Anonymous Coward",birthday=010101,slptm=0.1,theline,...) { name <-as.character(name) # how about this: if ( !is.numeric(birthday)) birthday<-length(strsplit(birthday,split="")) #set.seed guarantees same runif for given seed set.seed(birthday) numvert<-5 + round(runif(1)*15,0) x<-runif(numvert) y<-runif(numvert) max<-length(x) # add a point afterwards... trust me this will work x[(length(x)+1)]<-x[1] y[(length(y)+1)]<-y[1] #idiot (never mind what I did wrong the first time) plot(c(min(x),max(x)), c(min(y),max(y)), main=name, type='n', xlab='', ylab='', xaxt='n', yaxt='n', col.main="paleturquoise3") #now start the loop # set a rainbow palette.. look up nice color numbers colist<-rainbow(40) title(sub=theline,col.sub='paleturquoise3') for (i in 1:40) #adjust if looks sloppy { #lines x to y plus final connector lines(x,y,col=colist[i]) #lines(c(x[1],x[max]),c(y[1],y[max])) #cat(i,colist[i],"\n") #shift x,y[j] towards next x,y[j+1] pair xln<-mapply(function(x,a) x+0.04*(a-x),x[1:max],x[2:(max+1)]) yln<-mapply(function(x,a) x+0.04*(a-x),y[1:max],y[2:(max+1)]) x<-c(xln,xln[1]) y<-c(yln,yln[1]) syscall<-paste('sleep',slptm,sep=" ") system(syscall) } }