Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/*
__________________________________________________________
ASSIGNMENT 1 : INTERACTIVE DRAWING
"The Goldfish's Dilemma" by Nicklas Steffensen 991 318 977
__________________________________________________________
*/

//Sets the window size to 400px by 400px, and enables anti-aliasing
void setup(){
  size (400, 400);
  smooth (0);
  rectMode(CENTER);
  ellipseMode(CENTER);
}



void draw (){
    //since the ocean is most prevalent colour in the image, the background colour is set to a dark blue
    background (#010246);
    noStroke ();
    
    //creates a sky colour gradient that goes from bright blue (daytime) to a dark red (sunset) based on the x position of the mouse. The rate at which the RGB value decreases was slowed by dividing the mouseX value in half, creating a slower transition of colour 
    fill (50, 0, 255-(mouseX/2));
    rect (200, 0, 400, 320);
    

    //the fisherman's torso
    fill (#5A0705);
    rect (350, 100, 60, 90);
    rect (305, 100, 30, 50); 
    triangle (320, 55, 320, 75, 290, 75);

    //the fisherman's scarf
    fill (#FFCF67);
    rect (350, 35, 60, 35);
    
    //the fisherman's head     
    fill (#CB0000);
    rect (350, 55, 60, 5); 
    
    //the fisherman's cap
    fill (#008110);
    rect (350, 25, 60, 15);
    stroke(0);
    strokeWeight(3);
    line (380, 30, 300, 30);
    

    //the hem of the fishermna's sleeve
    stroke(0);
    strokeWeight(2);
    line (320, 75, 320, 100);

    //the fishing rod
    stroke(0);
    strokeWeight(5);
    line (320, 120, 200, 60);
    
    noStroke();
    

    //the fishing boat
    fill (#868686);
    triangle (300, 160, 260, 100, 300, 100);
    rect (500, 130, 400, 60);
    
    //the goldfish
    fill (#FA4700);
    //the dorsel fins of the goldfish; the coordinates are mapped to the mouse's x and y coordinates to ensure they move in tandem
    triangle (mouseX-30, mouseY, mouseX-60, mouseY-30, mouseX-70, mouseY-10);  
    triangle (mouseX-30, mouseY, mouseX-60, mouseY+30, mouseX-70, mouseY+10);
    //the goldfish's body
    ellipse (mouseX, mouseY, 75, 50);
    //creates parameters for a thin black line (the fishing line)
    stroke(0);
    strokeWeight(1);
    //the fishing line 
    line (200, 60, mouseX+38, mouseY);
    
    fill (0);
    //the goldfish's eye
    ellipse (mouseX+20, mouseY-10, 5, 5);
}

//prints the sort of dialogue you'd expect to hear from a goldfish whenever the mouse is clicked 
void mouseClicked() {
  println("*glub glub*");
}