Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/* 
 Name: Alex Cheung
 Class: Introduction to Media Computation
 Assignment: 1
 Reference image(s) used:
 https://upload.wikimedia.org/wikipedia/commons/2/20/Window_Porto_Covo_August_2013-2.jpg
 
 Free grid at the bottom!
 */



// The following is displayed on play.
void setup() {
  // Set the size of the canvas to 400px(width) x 400px(height).
  size(400, 400);
  // Fill the background with white.
  background(225, 232, 238);
  // Set the way rectangles are drawn to corner to corner.
  rectMode(CORNERS);
}

// Only using this for a minor creepyness factor.
float r;
float r2;
float r3;

// The following is displayed on each frame.
void draw() {
  // Fill the background with white on each frame.
  background(225, 232, 238);

  // Interior
  fill(0);
  noStroke();
  rect(100, 100, 300, 125);
  fill(25);
  rect(100, 125, 300, 150);
  fill(50);
  rect(100, 150, 300, 175);
  fill(75);
  rect(100, 175, 300, 200);
  fill(100);
  rect(100, 200, 300, 225);
  fill(125);
  rect(100, 225, 300, 250);
  fill(150);
  rect(100, 250, 300, 275);
  fill(175);
  rect(100, 275, 300, 300);

  // Draw Coffin
  stroke(158, 119, 88);
  strokeWeight(5);
  fill(159, 107, 71);
  quad(175, 125, 225, 125, 250, 175, 150, 175);
  quad(150, 175, 175, 300, 225, 300, 250, 175);
  fill(0); // Text colour
  text("Here lies...", 173, 175);

  // Draw Curtain
  noStroke();
  // 1
  fill(60, 81, 112);
  rect(100, 100, 105, 270-mouseY/4.4);
  fill(73, 98, 128);
  rect(105, 100, 110, 271-mouseY/4.3);
  fill(198, 214, 229);
  rect(110, 100, 115, 272-mouseY/4.2);
  fill(73, 98, 128);
  rect(115, 100, 120, 271-mouseY/4.1);
  fill(60, 81, 112);
  rect(120, 100, 125, 270-mouseY/4);

  // 2 
  fill(60, 81, 112);
  rect(125, 100, 130, 270-mouseY/3.9);
  fill(73, 98, 128);
  rect(130, 100, 135, 271-mouseY/3.8);
  fill(198, 214, 229);
  rect(135, 100, 140, 272-mouseY/3.7);
  fill(73, 98, 128);
  rect(140, 100, 145, 271-mouseY/3.6);
  fill(60, 81, 112);
  rect(145, 100, 150, 270-mouseY/3.5);

  // 3
  fill(60, 81, 112);
  rect(150, 100, 155, 270-mouseY/3.4);
  fill(73, 98, 128);
  rect(155, 100, 160, 271-mouseY/3.3);
  fill(198, 214, 229);
  rect(160, 100, 165, 272-mouseY/3.2);
  fill(73, 98, 128);
  rect(165, 100, 170, 271-mouseY/3.1);
  fill(60, 81, 112);
  rect(170, 100, 175, 270-mouseY/3);

  // 4
  fill(60, 81, 112);
  rect(175, 100, 180, 270-mouseY/2.9);
  fill(73, 98, 128);
  rect(180, 100, 185, 271-mouseY/2.8);
  fill(198, 214, 229);
  rect(185, 100, 190, 272-mouseY/2.7);
  fill(73, 98, 128);
  rect(190, 100, 195, 271-mouseY/2.6);
  fill(60, 81, 112);
  rect(195, 100, 200, 270-mouseY/2.5);

  // 5
  fill(60, 81, 112);
  rect(200, 100, 205, 270-mouseY/2.5);
  fill(73, 98, 128);
  rect(205, 100, 210, 271-mouseY/2.6);
  fill(198, 214, 229);
  rect(210, 100, 215, 272-mouseY/2.7);
  fill(73, 98, 128);
  rect(215, 100, 220, 271-mouseY/2.8);
  fill(60, 81, 112);
  rect(220, 100, 225, 270-mouseY/2.9);

  // 6
  fill(60, 81, 112);
  rect(225, 100, 230, 270-mouseY/3);
  fill(73, 98, 128);
  rect(230, 100, 235, 271-mouseY/3.1);
  fill(198, 214, 229);
  rect(235, 100, 240, 272-mouseY/3.2);
  fill(73, 98, 128);
  rect(240, 100, 245, 271-mouseY/3.3);
  fill(60, 81, 112);
  rect(245, 100, 250, 270-mouseY/3.4);

  // 7
  fill(60, 81, 112);
  rect(250, 100, 255, 270-mouseY/3.5);
  fill(73, 98, 128);
  rect(255, 100, 260, 271-mouseY/3.6);
  fill(198, 214, 229);
  rect(260, 100, 265, 272-mouseY/3.7);
  fill(73, 98, 128);
  rect(265, 100, 270, 271-mouseY/3.8);
  fill(60, 81, 112);
  rect(270, 100, 275, 270-mouseY/3.9);

  // 8
  fill(60, 81, 112);
  rect(275, 100, 280, 270-mouseY/4);
  fill(73, 98, 128);
  rect(280, 100, 285, 271-mouseY/4.1);
  fill(198, 214, 229);
  rect(285, 100, 290, 272-mouseY/4.2);
  fill(73, 98, 128);
  rect(290, 100, 295, 271-mouseY/4.3);
  fill(60, 81, 112);
  rect(295, 100, 300, 270-mouseY/4.4);

  // Draw LEFT openable window
  fill(94, 51, 42);
  rect(100, 100, 110, 300);
  rect(145-mouseX/8.88, 100, 155-mouseX/8.88, 300);
  rect(190-mouseX/4.44, 100, 200-mouseX/4.44, 300);

  // Top
  rect(100, 100, 110, 125);
  rect(110-mouseX/40, 100, 120-mouseX/40, 125); // 400/10=40
  rect(120-mouseX/20, 100, 130-mouseX/20, 125); // 400/20=20
  rect(130-mouseX/13.33, 100, 140-mouseX/13.33, 125); // 400/30=13.33
  rect(140-mouseX/10, 100, 150-mouseX/10, 125); // 400/40=10
  rect(150-mouseX/8, 100, 160-mouseX/8, 125); // 400/50=8
  rect(160-mouseX/6.66, 100, 170-mouseX/6.66, 125); // 400/60=6.66
  rect(170-mouseX/5.71, 100, 180-mouseX/5.71, 125); // 400/70=5.71
  rect(180-mouseX/5, 100, 190-mouseX/5, 125); // 400/80=5
  rect(190-mouseX/4.44, 100, 200-mouseX/4.44, 125); // 400/90=4.44

  // Middle
  rect(100, 195, 110, 205);
  rect(110-mouseX/40, 195, 120-mouseX/40, 205);
  rect(120-mouseX/20, 195, 130-mouseX/20, 205);
  rect(130-mouseX/13.33, 195, 140-mouseX/13.33, 205);
  rect(140-mouseX/10, 195, 150-mouseX/10, 205);
  rect(150-mouseX/8, 195, 160-mouseX/8, 205);
  rect(160-mouseX/6.66, 195, 170-mouseX/6.66, 205);
  rect(170-mouseX/5.71, 195, 180-mouseX/5.71, 205);
  rect(180-mouseX/5, 195, 190-mouseX/5, 205);
  rect(190-mouseX/4.44, 195, 200-mouseX/4.44, 205);

  // Bottom
  rect(100, 275, 110, 300);
  rect(110-mouseX/40, 275, 120-mouseX/40, 300);
  rect(120-mouseX/20, 275, 130-mouseX/20, 300);
  rect(130-mouseX/13.33, 275, 140-mouseX/13.33, 300);
  rect(140-mouseX/10, 275, 150-mouseX/10, 300);
  rect(150-mouseX/8, 275, 160-mouseX/8, 300);
  rect(160-mouseX/6.66, 275, 170-mouseX/6.66, 300);
  rect(170-mouseX/5.71, 275, 180-mouseX/5.71, 300);
  rect(180-mouseX/5, 275, 190-mouseX/5, 300);
  rect(190-mouseX/4.44, 275, 200-mouseX/4.44, 300);

  // Draw RIGHT window
  fill(94, 51, 42);
  rect(200, 100, 210, 300);
  rect(245, 100, 255, 300);
  rect(290, 100, 300, 300);

  // Top
  rect(200, 100, 210, 125);
  rect(210, 100, 225, 125);
  rect(220, 100, 230, 125);
  rect(230, 100, 240, 125);
  rect(240, 100, 250, 125);
  rect(250, 100, 260, 125);
  rect(260, 100, 270, 125);
  rect(270, 100, 280, 125);
  rect(280, 100, 290, 125);
  rect(290, 100, 300, 125);

  // Middle
  rect(200, 195, 210, 205);
  rect(210, 195, 220, 205);
  rect(220, 195, 230, 205);
  rect(230, 195, 240, 205);
  rect(240, 195, 250, 205);
  rect(250, 195, 260, 205);
  rect(260, 195, 270, 205);
  rect(270, 195, 280, 205);
  rect(280, 195, 290, 205);
  rect(290, 195, 300, 205);

  // Bottom
  rect(200, 275, 210, 300);
  rect(210, 275, 220, 300);
  rect(220, 275, 230, 300);
  rect(230, 275, 240, 300);
  rect(240, 275, 250, 300);
  rect(250, 275, 260, 300);
  rect(260, 275, 270, 300);
  rect(270, 275, 280, 300);
  rect(280, 275, 290, 300);
  rect(290, 275, 300, 300);

  // Draw window outter frame.
  noStroke();
  fill(64, 127, 207);
  rect(75, 75, 100, 325);
  rect(75, 75, 325, 100);
  rect(300, 75, 325, 325);
  rect(75, 300, 325, 325);

  // Draw shadow.
  noStroke();
  fill(0, 90);
  quad(25, 100, 25, 300, 0, 325, 0, 125);
  quad(75, 300, 75, 325, 0, 325, 25, 300);
  quad(325, 325, 320, 330, 70, 330, 70, 325);
  quad(375, 300, 365, 315, 75, 315, 75, 300);

  // Draw window inner frame.
  noFill();
  stroke(230, 226, 214);
  strokeWeight(10);
  rect(100, 100, 300, 300);

  // Fill the following shapes with brown.
  fill(94, 51, 42);
  // Set the stroke/outline colour to a darker brown.
  stroke(75, 31, 22);
  // Set the thickness of the outline to be more thick.
  strokeWeight(5);

  // Draw left shutter.
  rect(25, 100, 100, 300); // General shape
  // Flippy thing
  fill(80, 40, 30);
  rect(40, 120, 85, 140); 
  rect(40, 140, 85, 160);
  rect(40, 160, 85, 180);
  rect(40, 180, 85, 200);
  rect(40, 200, 85, 220);
  rect(40, 220, 85, 240);
  rect(40, 240, 85, 260);
  rect(40, 260, 85, 280);

  // Fill the following shapes with brown.
  fill(94, 51, 42);
  // Set the stroke/outline colour to a darker brown.
  stroke(75, 31, 22);
  // Set the thickness of the outline to be more thick.
  strokeWeight(5);

  // Draw right shutter.
  rect(300, 100, 375, 300);
  // Flippy thing
  fill(80, 40, 30);
  rect(315, 120, 360, 140); 
  rect(315, 140, 360, 160);
  rect(315, 160, 360, 180);
  rect(315, 180, 360, 200);
  rect(315, 200, 360, 220);
  rect(315, 220, 360, 240);
  rect(315, 240, 360, 260);
  rect(315, 260, 360, 280);

  /*
  // Grid, for determining placement
   stroke(0); // Black grid lines
   strokeWeight(1); // Grid line thickness
   fill(255, 0, 0); // Text colour
   // Verticle
   line(25, 0, 25, 400);
   line(50, 0, 50, 400);
   line(75, 0, 75, 400);
   line(100, 0, 100, 400);
   line(125, 0, 125, 400);
   line(150, 0, 150, 400);
   line(175, 0, 175, 400);
   line(200, 0, 200, 400);
   line(225, 0, 225, 400);
   line(250, 0, 250, 400);
   line(275, 0, 275, 400);
   line(300, 0, 300, 400);
   line(325, 0, 325, 400);
   line(350, 0, 350, 400);
   line(375, 0, 375, 400);
   
   text("25", 0, 25);
   text("50", 0, 50);
   text("75", 0, 75);
   text("100", 0, 100);
   text("125", 0, 125);
   text("150", 0, 150);
   text("175", 0, 175);
   text("200", 0, 200);
   text("225", 0, 225);
   text("250", 0, 250);
   text("275", 0, 275);
   text("300", 0, 300);
   text("325", 0, 325);
   text("350", 0, 350);
   text("375", 0, 375);
   
   // Horizontal
   line(0, 25, 400, 25);
   line(0, 50, 400, 50);
   line(0, 75, 400, 75);
   line(0, 100, 400, 100);
   line(0, 125, 400, 125);
   line(0, 150, 400, 150);
   line(0, 175, 400, 175);
   line(0, 200, 400, 200);
   line(0, 225, 400, 225);
   line(0, 250, 400, 250);
   line(0, 275, 400, 275);
   line(0, 300, 400, 300);
   line(0, 325, 400, 325);
   line(0, 350, 400, 350);
   line(0, 375, 400, 375);
   
   text("0", 1, 400);
   text("25", 26, 400);
   text("50", 51, 400);
   text("75", 76, 400);
   text("100", 101, 400);
   text("125", 126, 400);
   text("150", 151, 400);
   text("175", 176, 400);
   text("200", 201, 400);
   text("225", 226, 400);
   text("250", 251, 400);
   text("275", 276, 400);
   text("300", 301, 400);
   text("325", 326, 400);
   text("350", 351, 400);
   text("375", 376, 400);
   */
}

void mouseMoved() {
  // Draw Ghost
  noStroke();
  fill(255, 224); // Fill with white.
  ellipseMode(CENTER); // Set so that ellipses are drawn from the center of a set of coords, outwards.
  ellipse(200, 200, 75, 75); // "Head"

  // Body
  triangle(162.5, 200, 162.5, 275, 200, 200); 
  triangle(175, 200, 187.5, 275, 200, 237.5);
  triangle(225, 200, 217.5, 275, 200, 237.5);
  triangle(237.5, 200, 237.5, 275, 200, 200);

  fill(255, 0, 0); // Fill eyes with red
  ellipse(185, 190, 20, 30); // Left eye
  ellipse(215, 190, 20, 30); // Right eye

  r = random(400);
  r2 = random(400);
  r3 = random(400); 
  ellipse(r, r2, r3, r3+10); // Left eye
  ellipse(r+30, r2, r3, r3+10); // Right eye
}