Coding- Processing task- Java

Today i had to create an array of colours and randomly fill a square with one of the colours from your array when the mouse is clicked.

The code i used 
//size of the canvas
void setup (){
size (600,300);

// choice of colours using colour chart
int rColor = int(random(0,7));
color[] myColors ={#B77EC9,#863A7C,#3DE06A,#ED5B22,#EDE322,#FF0527,#05FFFD,#FFF705};
//draw, size and colour of my shape

void draw () {
size (200,200);
rect(80,80, 80,80);
//what happens(colour changes) when mouse is clicked
void mouseClicked (){
rColor= int(random(0,7));


If you add more colours you must make sure you change the number in the section mouse clicked to make sure the colours get picked up.

Screen Shot 2014-10-16 at 16.13.08


Task on programming

Today I have learnt how to do programming independently, reflecting back on what I have learnt in the previous week; such as constructing a circle and then being able to change the colour, the number of circles present and the function of when the mouse is clicked. Below is the actual layout in my program and some screenshots of my outcomes. I found the most difficult part was being able to find any small mistakes I had made then correct them so that the program could run.

int numberOfCircles = 10;
void setup () {
println (“setting up our program”);
size (600,300);
background (0);


void draw() {

while (numberOfCircles > 0) {
println(“drawing my circle”);
float circleSize= random(20,60);
ellipse (random(width), random(height), 20, 20);
fill (random (255), random (255), random (255)) ;


void mouseClicked() {
numberOfCircles = 10;
//what happens when the mouse is clicked


Screen Shot 2014-10-09 at 16.38.11 Screen Shot 2014-10-09 at 16.25.31


Today I had my first workshop on how to do some basic processing; for someone who has not used anything like this before I did feel a bit like my brain had melted by the end. However I managed to complete the task and make a circle move around the page as well as getting the colour of the background to change depending on the x and y coordinates of the user clicking on the mouse. I did this all from scratch and have learnt some of the basic programming key terms and commands. The most important keys on my laptop have now become ( ) ; { } / and =. Overall I would say my first attempt was successful!

Screen Shot 2014-10-02 at 16.44.41 Screen Shot 2014-10-02 at 16.44.36