Skip to content

Instantly share code, notes, and snippets.

@rsuniev
Created May 19, 2011 15:41
Show Gist options
  • Save rsuniev/981060 to your computer and use it in GitHub Desktop.
Save rsuniev/981060 to your computer and use it in GitHub Desktop.
SPDE example
smooth()
noStroke()
fill(226)
frameRate(10)
size(400,400)
case class Color(red:Int,blue:Int,green:Int)
case class Ball(x:Int,y:Int,color:Color,radius:Int)
def draw {
Stream.continually(makeBall) take 10 map drawBall
}
def rand(in:Int):Int = {
util.Random.nextInt(in)
}
def makeBall():Ball = {
val color = Color(rand(256),rand(256),rand(256))
Ball(rand(400),rand(400),color,rand(70))
}
def drawBall(ball:Ball){
val c = ball.color
fill(c.red,c.green,c.blue)
ellipse(ball.x,ball.y,ball.radius,ball.radius)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment