R/butterflies.R

"butterflies" <-
function (num=c(100, 10), scale=c(.03, .1), 
	color=grep("^gray", colors(), value=TRUE), seed=NULL)
{
	if(length(seed)) set.seed(seed)

	n <- max(length(num), length(scale))
	num <- rep(num, length=n)
	scale <- rep(scale, length=n)

	canvas()
	for(j in 1:n) {
		sj <- scale[j]
		for(i in 1:num[j]) {
			butterfly(loc=runif(2, sj, 1-sj), scale=sj, 
				color=safesample(color))
		}
	}
}

Try the TaoTeProgramming package in your browser

Any scripts or data that you put into this service are public.

TaoTeProgramming documentation built on May 1, 2019, 6:47 p.m.