Workshop 3 (Processing 2)

Today I had another workshop using Processing.

We went over data types again such as boolean (true or false), string (text), etc. I was given a task to create a program which drew 10 circles, all of which were random sizes and colours and appeared at random points on the canvas, then when a user clicked the mouse the staged cleared. Below I will break down my code:

void setup() {
println(“program is starting”);

This is my “setup” it tells the program the basics, mine is saying make the canvas (600 pixels in the x and 300 pixels in the y) and set the background colour to black. it also has a print line which just prints whatever I type which in the println to the console.

int circles = 10;

This bit of code sets a name to a piece of data so in my program circles = 10.

void draw() {
println(“circles were drawn”);

while (circles > 0) {
float circleSize = random(20,80);
ellipse(random(width),random(height), circleSize, circleSize);
fill( random(255), random(255), random(255), random(255));




now the draw is used to create the circles, my code is telling the program to create a circle that is a random size and colour and is placed randomly on the screen. It is also within a loop and is saying while circles is greater then 0 (which we set using int circles = 10;) which would also be true if not for the circles–; which is telling my program every time you loop take 1 from the circle value so until it reaches 0 it will raw a circle and as the value starts off at 10 it will create 10 circles.

void mouseClicked(){



Now this bit of code is telling the program to do something when the uses clicks, however my clearStage function is below

void clearStage(){
background(random(255), random(255), random(255));
println(“Mouse was clicked”);

So this is telling the program whenever the clearStage function is called set the background colour back to black.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s