Skip to content

Instantly share code, notes, and snippets.

@homerhanumat
Created March 8, 2018 18:31
Show Gist options
  • Save homerhanumat/8840329fe16e690e704c2a763670c0ba to your computer and use it in GitHub Desktop.
Save homerhanumat/8840329fe16e690e704c2a763670c0ba to your computer and use it in GitHub Desktop.
Suggestion for Celeste
## Experiment with the constants below (e.g., the 5, 25, 8, etc.) so see if you can get the effect you want.
## Note that wrapping the loop in turtle_do makes it run a good bit faster
## Also think about what you can do to keep the turtle tracing over itself when it repeats 50 drips
library(TurtleGraphics)
turtle_drip_pollack<-function(n=50){
turtle_init(75,75, mode = "clip")
repeat {
for( i in 1:n){
turtle_do({
randomColor <- sample(colors(), size = 1)
randomLength <- runif(1, min = 5, max = 25)
randomWidth <- runif(1, min = 1, max = 30)
turtle_col(col=randomColor)
turtle_up()
turtle_forward(randomLength)
turtle_down()
turtle_lwd(lwd=randomWidth)
turtle_forward(randomWidth/8)
turtle_up()
turtle_backward(randomWidth/8)
turtle_backward(randomLength)
turtle_down()
turtle_turn(360/n)
})
}
move <- readline(prompt = "More drops? (enter q to quit): ")
if ( move == "q") break
}
cat("What a beauty!")
}
turtle_drip_pollack()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment