Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
//   _____     _____    __   _   _   _______       _         _____     _____    _   __
//  | ___ \   / ___ \  |  \ | | | | |__   __|     | |       / ___ \   / ___ \  | |_/ /
//  | |  | | | |   | | |   \| | |/     | |        | |      | |   | | | |   | | |  _ <
//  | |__| | | |___| | | |\   |        | |        | |____  | |___| | | |___| | | | \ \
//  |_____/   \_____/  |_| \__|        |_|        |______|  \_____/   \_____/  |_|  \_\
//                                ____   _         _____    _____   ______   _______
//            _____       __     / ___\ | |       / ___ \  / ___/  |  ____| |__   __|
//    | |\ |    |   |__| |__    | |     | |      | |   | | \___ \  |  ___|     | |
//    | | \|    |   |  | |__    | |____ | |____  | |___| |  ___| | | |____     | |
//                               \____/ |______|  \_____/  |____/  |______|    |_|
//  
//     When it's dark, your mind makes you see things that aren't really there
//
//   Move the mouse across the screen to open the closet door
//   Click to turn on the lights
//   Press any button to turn lights off again
//
//   Stare into the darkness for long enough and they'll appear

void setup() {
  size(400,400);
}

// Darkness Modifier
float dark = 64;
// Darkness Length
float darktime = 0;

void draw() {
  
  noStroke();
  float dx = mouseX/4+140;
  float dy = -0.004*pow(dx-240,2)+140;
  float dl = sqrt(pow(260-dx,2)+pow(100-dy,2));
  float bx = -(mouseX/40+7)*((260-dx)/dl);
  float by = -(mouseX/40+7)*((100-dy)/dl+1);
  
  // Back Wall
  background(78-dark,124-dark,201-dark);
  
  // Floor
  fill(140-dark,209-dark,147-dark);
  rect(0,280,400,120);
  
  // Closet Side Walls
  fill(78-dark,124-dark,201-dark);
  
  quad(130,100,160,115,160,280,135,320);
  quad(270,100,240,115,240,280,265,320);
  
  // Closet Darkness
  fill(0,0,0,dark*4);
  rect(140,100,120,220);
  
  // Eyes
  ellipseMode(CENTER);
  fill(255,0,35,(((darktime)-128))*(dark/64));
  ellipse(190,300,8,8); //1
  ellipse(205,295,8,8);
  fill(255,0,35,(((darktime)-256))*(dark/64));
  ellipse(150,275,4,4); //2
  ellipse(158,282,4,4);
  fill(255,0,35,(((darktime)-384))*(dark/64));
  ellipse(177,259,10,10); //3
  ellipse(193,261,10,10);
  fill(255,0,35,(((darktime)-512))*(dark/64));
  ellipse(195,235,4,4); //4
  ellipse(203,238,4,4);
  fill(255,0,35,(((darktime)-640))*(dark/64));
  ellipse(150,227,4,4); //5
  ellipse(158,222,4,4);
  fill(255,0,35,(((darktime)-768))*(dark/64));
  ellipse(198,205,10,10); //6
  ellipse(213,210,10,10);
  fill(255,0,35,(((darktime)-896))*(dark/64));
  ellipse(155,193,12,12); //7
  ellipse(174,191,12,12);
  fill(255,0,35,(((darktime)-1024))*(dark/64));
  ellipse(199,174,6,6); //8
  ellipse(210,169,6,6);
  fill(255,0,35,(((darktime)-1152))*(dark/64));
  ellipse(155,166,6,6); //9
  ellipse(165,167,6,6);
  fill(255,0,35,(((darktime)-1280))*(dark/64));
  ellipse(170,135,18,18); //10
  ellipse(200,135,18,18);
  
  //Front Wall
  fill(78-dark,124-dark,201-dark);
  rect(0,0,400,95);
  rect(0,95,135,225);
  rect(265,95,135,225);
  
  //Door Back
  fill(255-dark,198-dark, 146-dark);
  quad(dx+bx,dy+by,dx,dy,dx,dy+220,dx+bx,dy+220+by);
  quad(dx+bx,dy+by,260+bx,100+by,260,100,dx,dy);
  
  // Door Frame
  fill(93-dark,174-dark,199-dark);
  rect(130,80,140,10);
  fill(113-dark,194-dark,209-dark);
  rect(130,90,140,10);
  rect(130,100,10,225);
  rect(260,100,10,225);
  
  // Door
  fill(255-dark,228-dark,159-dark);
  quad(dx,dy,260,100,260,320,dx,dy+220);
  
  darktime = darktime+1;
}

void mousePressed() {
  // Turn On Lights
  dark = 0;
}
void keyPressed() {
  //Turn Off Lights
  dark = 64;
  darktime = 0;
}