Created
May 19, 2011 15:41
-
-
Save rsuniev/981060 to your computer and use it in GitHub Desktop.
SPDE example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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