Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/*
 Name: Samuel Barnes
 Due: September 17, 2018
 Title: midsummer_night
 Description: In Iceland, they say that under certain circumstances, elves will bring you gifts...
 */

void setup()
{
  // set display window to 400 by 400 pixels
  size(400, 400);
}

void draw()
{
  // reset background to colour of sky
  background(20, 20, 35);


  /* PANEL 2 */


  // STARS
  // glow
  noStroke();
  fill(255, 255, 255, 8 + sin(frameCount * 0.01));
  ellipse(240, 340 - (mouseY / (height * 1.0)) * 100, 20 + sin(frameCount * 0.02) * 5, 20 + sin(frameCount * 0.02) * 5);
  ellipse(340, 360 - (mouseY / (height * 1.0)) * 100, 20 + sin(frameCount * 0.02) * 5, 20 + sin(frameCount * 0.02) * 5);
  ellipse(40, 360 - (mouseY / (height * 1.0)) * 100, 20 + sin(frameCount * 0.02) * 5, 20 + sin(frameCount * 0.02) * 5);
  ellipse(20, 240 - (mouseY / (height * 1.0)) * 100, 20 + sin(frameCount * 0.02) * 5, 20 + sin(frameCount * 0.02) * 5);
  ellipse(60, 285 - (mouseY / (height * 1.0)) * 100, 20 + sin(frameCount * 0.02) * 5, 20 + sin(frameCount * 0.02) * 5);
  ellipse(120, 240 - (mouseY / (height * 1.0)) * 100, 20 + sin(frameCount * 0.02) * 5, 20 + sin(frameCount * 0.02) * 5);
  ellipse(180, 260 - (mouseY / (height * 1.0)) * 100, 20 + sin(frameCount * 0.02) * 5, 20 + sin(frameCount * 0.02) * 5);
  ellipse(240, 220 - (mouseY / (height * 1.0)) * 100, 20 + sin(frameCount * 0.02) * 5, 20 + sin(frameCount * 0.02) * 5);
  ellipse(300, 280 - (mouseY / (height * 1.0)) * 100, 20 + sin(frameCount * 0.02) * 5, 20 + sin(frameCount * 0.02) * 5);
  ellipse(340, 240 - (mouseY / (height * 1.0)) * 100, 20 + sin(frameCount * 0.02) * 5, 20 + sin(frameCount * 0.02) * 5);
  // stars
  stroke(255);
  strokeWeight(1);
  point(240, 340 - (mouseY / (height * 1.0)) * 100);
  point(340, 360 - (mouseY / (height * 1.0)) * 100);
  point(40, 360  - (mouseY / (height * 1.0)) * 100);
  point(20, 240 - (mouseY / (height * 1.0)) * 100);
  point(60, 285 - (mouseY / (height * 1.0)) * 100);
  point(120, 240 - (mouseY / (height * 1.0)) * 100);
  point(180, 260 - (mouseY / (height * 1.0)) * 100);
  point(240, 220 - (mouseY / (height * 1.0)) * 100);
  point(300, 280 - (mouseY / (height * 1.0)) * 100);
  point(340, 240 - (mouseY / (height * 1.0)) * 100);

  // MOUNTAIN 1
  // shadow
  noStroke();
  fill(41, 64, 59, 128);
  triangle(270, 370 - (mouseY / (height * 1.0)) * 100, 50, 500 - (mouseY / (height * 1.0)) * 100, 550, 500 - (mouseY / (height * 1.0)) * 100);
  // mountain
  fill(38, 72, 61, 128);
  triangle(270, 370 - (mouseY / (height * 1.0)) * 100, 50, 500 - (mouseY / (height * 1.0)) * 100, 450, 500 - (mouseY / (height * 1.0)) * 100);

  // MOUNTAIN 2
  // shadow
  fill(41, 64, 59);
  triangle(120, 320 - (mouseY / (height * 1.0)) * 100, -100, 500 - (mouseY / (height * 1.0)) * 100, 400, 500 - (mouseY / (height * 1.0)) * 100);
  // mountain
  fill(38, 72, 61);
  triangle(120, 320 - (mouseY / (height * 1.0)) * 100, 0, 500 - (mouseY / (height * 1.0)) * 100, 400, 500 - (mouseY / (height * 1.0)) * 100);

  // GROUND
  rectMode(CORNERS);
  fill(49, 93, 69);
  rect(0, 465 - (mouseY / (height * 1.0)) * 100, 400, 500 - (mouseY / (height * 1.0)) * 100);

  // CHURCH
  // walls
  noStroke();
  fill(255);
  rect(80, 430 - (mouseY / (height * 1.0)) * 100, 140, 470 - (mouseY / (height * 1.0)) * 100);
  // roof
  fill(91, 138, 201);
  rect(78, 429 - (mouseY / (height * 1.0)) * 100, 142, 450 - (mouseY / (height * 1.0)) * 100);
  // tower
  fill(255);
  rect(82, 420 - (mouseY / (height * 1.0)) * 100, 92, 435 - (mouseY / (height * 1.0)) * 100);
  // tower roof
  noStroke();
  fill(91, 138, 201);
  triangle(80, 420 - (mouseY / (height * 1.0)) * 100, 94, 420 - (mouseY / (height * 1.0)) * 100, 87, 405 - (mouseY / (height * 1.0)) * 100);


  /* PANEL 1 */


  // SKIN
  rectMode(CORNERS);
  fill(255, 243, 240);
  rect(0, 0, 400, 200);

  // EYES
  fill(255);
  // right eye
  ellipse(100, 100, 100, 100);
  // left eye
  ellipse(300, 100, 100, 100);

  // IRISES
  fill(96, 130, 170);
  // right eye
  ellipse(85 + (mouseX / (width * 1.0)) * 30, 85 + (mouseY / (height * 1.0)) * 30, 50, 50);
  // left eye
  ellipse(285 + (mouseX / (width * 1.0)) * 30, 85 + (mouseY / (height * 1.0)) * 30, 50, 50);

  // PUPILS
  fill(0);
  // right eye
  ellipse(85 + (mouseX / (width * 1.0)) * 30, 85 + (mouseY / (height * 1.0)) * 30, 20, 20);
  // left eye
  ellipse(285 + (mouseX / (width * 1.0)) * 30, 85 + (mouseY / (height * 1.0)) * 30, 20, 20);

  // TWINKLES
  fill(255, 255, 255, 255 - (mouseY / (height * 1.0)) * 255);
  // right eye
  ellipse(85 + (mouseX / (width * 1.0)) * 30, 85 + (mouseY / (height * 1.0)) * 30, 5, 5);
  // left eye
  ellipse(285 + (mouseX / (width * 1.0)) * 30, 85 + (mouseY / (height * 1.0)) * 30, 5, 5);

  // EYE LIDS
  stroke(255, 226, 219);
  strokeWeight(25);
  noFill();
  // right eye, top lid
  arc(100, 100, 100, 100 - (mouseY / (height * 1.0)) * 25, PI, TWO_PI);
  // right eye, bottom lid
  arc(100, 100, 100, 100 - (mouseY / (height * 1.0)) * 25, 0, PI);
  // left eye, top lid
  arc(300, 100, 100, 100 - (mouseY / (height * 1.0)) * 25, PI, TWO_PI);
  // left eye, bottom lid
  arc(300, 100, 100, 100 - (mouseY / (height * 1.0)) * 25, 0, PI);

  // EYE BROWS
  noFill();
  stroke(92, 64, 51);
  strokeWeight(25);
  // right brow
  arc(100, 50 + (mouseY / (height * 1.0)) * 25, 125, 100, PI+QUARTER_PI, TWO_PI-QUARTER_PI);
  // left brow
  arc(300, 50 + (mouseY / (height * 1.0)) * 25, 125, 100, PI+QUARTER_PI, TWO_PI-QUARTER_PI);

  // NOSE
  noStroke();
  fill(255, 172, 124);
  // nose
  triangle(200, 100, 150, 200, 250, 200);
  // shadow
  fill(216, 72, 50);
  triangle(200, 100, 190 + (mouseX / (width * 1.0)) * 20, 200, 250, 200);


  /* GUTTER */


  // gutter will separate panels
  noStroke();
  fill(0);
  rect(0, 190, 400, 210);
}

void mousePressed()
{
  println("It's already midnight... Would they mind if I threw a stone?");
}