Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
void setup() {
  //set size of window
  size(400, 400);
}

void draw() {
  //set background color (NIGHT sky)
  background(56, 27, 31);
  
  //draw stars
  stroke(255);
  strokeWeight(2);
  point(10, 20);
  point(40, 140);
  point(180, 90);
  point(120, 160);
  point(150, 120);
  point(290, 200);
  
  //draw stars (smaller + less bright)
  stroke(255, 80);
  strokeWeight(1.5);
  point(360, 90);
  point(260, 150);
  point(340, 160);
  point(240, 90);
  point(310, 70);
  point(20, 200);

  //set - shape modes
  ellipseMode(CENTER);
  rectMode(CORNERS);

  //set - no outline for shapes
  noStroke();

  //draw DAYTIME sky
  //sky becomes more opaque as mouse moves downwards 
  fill(109, 57, 67, mouseY);
  rect(0, 0, 400, 400);
  
  //draw Sun
  //beams will pulse slowly
  fill(133, 81, 89, mouseY);
  ellipse(200, 200, 400+10*sin(frameCount*.05), 400+10*sin(frameCount*.05));
  fill(158, 108, 119, mouseY);
  ellipse(200, 200, 330+8*sin(frameCount*.05), 330+8*sin(frameCount*.05));
  fill(185, 141, 150, mouseY);
  ellipse(200, 200, 250+6*sin(frameCount*.05), 250+6*sin(frameCount*.05));
  fill(210, 196, 199, mouseY);
  ellipse(200, 200, 170+4*sin(frameCount*.05), 170+4*sin(frameCount*.05));
  fill(245, 230, 230, mouseY);
  ellipse(200, 200, 90, 90);

  //draw Moon - changes position according to Y value
  //beams will pulse slowly
  fill(255);
  ellipse(80, mouseY+50, 50, 50);
  fill(255, 95);
  ellipse(80, mouseY+50, 70+5*sin(frameCount*.05), 70+5*sin(frameCount*.05));
  fill(255, 85);
  ellipse(80, mouseY+50, 100+5*sin(frameCount*.05), 100+5*sin(frameCount*.05));

  //draw GLOW of floating sparkles (background)
  //will pulse slowly  
  //bobs up and down at different rates
  fill(255, 95);
  ellipse(220, 20+2*sin(frameCount*.047)+mouseY, 2+5*sin(frameCount*.03), 2+5*sin(frameCount*.03));
  ellipse(340, 20+3*sin(frameCount*.043)+mouseY, 5+5*sin(frameCount*.04), 5+5*sin(frameCount*.04));
  ellipse(140, 60+2*sin(frameCount*.029)+mouseY, 3+5*sin(frameCount*.02), 3+5*sin(frameCount*.02));
  ellipse(20, 100+2*sin(frameCount*.032)+mouseY, 2+5*sin(frameCount*.045), 2+5*sin(frameCount*.045));
  ellipse(280, 100+4*sin(frameCount*.035)+mouseY, 4+5*sin(frameCount*.035), 4+4*sin(frameCount*.035));
  ellipse(390, 100+5*sin(frameCount*.047)+mouseY, 5+5*sin(frameCount*.025), 5+5*sin(frameCount*.025));
  ellipse(320, 140+2*sin(frameCount*.041)+mouseY, 5+5*sin(frameCount*.037), 5+5*sin(frameCount*.037));
  ellipse(40, 180+3*sin(frameCount*.032)+mouseY, 5+5*sin(frameCount*.042), 5+5*sin(frameCount*.042));

  //draw YELLOW CENTER of floating sparkles (background)
  //bobs in tandem with GLOW
  fill(246, 244, 145);
  ellipse(220, 20+2*sin(frameCount*.047)+mouseY, 2, 2);
  ellipse(340, 20+3*sin(frameCount*.043)+mouseY, 5, 5);
  ellipse(140, 60+2*sin(frameCount*.029)+mouseY, 3, 3);
  ellipse(20, 100+2*sin(frameCount*.032)+mouseY, 2, 2);
  ellipse(280, 100+4*sin(frameCount*.035)+mouseY, 4, 4);
  ellipse(390, 100+5*sin(frameCount*.047)+mouseY, 5, 5);
  ellipse(320, 140+2*sin(frameCount*.041)+mouseY, 5, 5);
  ellipse(40, 180+3*sin(frameCount*.032)+mouseY, 5, 5);

  //draw mountain 1 (center)
  fill(79, 46, 49);
  triangle(0, 260, 170, 180, 350, 260);

  //draw mountain 2 (left)
  fill(95, 51, 54);
  triangle(0, 260, 80, 160, 190, 260);

  //draw mountain 3 (right);
  fill(99, 43, 47);
  quad(290, 220, 320, 180, 400, 160, 400, 260);
  rect(290, 220, 400, 260);

  //draw tree foliage (backfill)
  fill(182, 109, 108);
  rect(150, 0, 270, 60);
  rect(180, 0, 400, 50);
  triangle(360, 70, 400, 40, 360, 0);

  //draw tree trunk
  fill(207, 198, 208);
  quad(240, 60, 260, 60, 340, 100, 350, 120);
  quad(300, 40, 320, 40, 360, 120, 350, 120);
  quad(350, 120, 360, 120, 380, 220, 380, 260);
  quad(380, 260, 375, 220, 390, 220, 400, 250);
  quad(380, 260, 370, 60, 380, 50, 390, 220);
  quad(380, 260, 380, 240, 400, 245, 400, 260);

  //draw tree foliage
  fill(182, 109, 108);
  quad(140, 0, 130, 30, 400, 30, 400, 0);
  quad(140, 0, 180, 60, 150, 70, 130, 30);
  quad(180, 60, 210, 70, 240, 60, 240, 0);
  quad(240, 40, 240, 60, 270, 60, 280, 50);
  quad(280, 50, 300, 60, 305, 50, 280, 0);
  quad(320, 40, 340, 80, 360, 70, 360, 0);
  quad(360, 70, 370, 75, 370, 0, 300, 0);
  quad(380, 50, 390, 60, 400, 60, 400, 0);

  //draw ground (middle plane)
  fill(126, 93, 105);
  rect(0, 260, 400, 400);

  //draw GLOW of floating sparkle (front of mountains)
  //will pulse slowly
  fill(255, 95);
  ellipse(110, 240+4*sin(frameCount*.039)+mouseY, 2+5*sin(frameCount*.028), 2+5*sin(frameCount*.028));

  //draw YELLOW CENTER of floating sparkle (front of mountains)
  //bobs in tandem with GLOW
  fill(246, 244, 145);
  ellipse(110, 240+4*sin(frameCount*.039)+mouseY, 2, 2);

  //draw ground (front)
  fill(150, 127, 136);
  rect(0, 320, 400, 400);

  //draw bush (back, left)
  fill(79, 37, 43);
  quad(0, 310, 0, 330, 145, 330, 150, 310);
  quad(0, 300, 0, 310, 130, 310, 125, 300);
  rect(0, 270, 110, 300);
  rect(0, 250, 80, 270);
  rect(20, 230, 40, 250);
  quad(0, 210, 0, 250, 20, 250, 20, 230);

  //draw bush (back, right)
  quad(400, 250, 380, 260, 380, 280, 400, 280);
  rect(360, 280, 400, 320);
  rect(340, 300, 360, 320);
  rect(330, 310, 340, 320);

  //draw GLOW of floating sparkles - (middle plane)
  //will pulse slowly
  //bobs up and down at different rates
  fill(255, 95);
  ellipse(20, 300+3*sin(frameCount*.035)+mouseY, 3+5*sin(frameCount*.047), 3+5*sin(frameCount*.047));
  ellipse(240, 300+4*sin(frameCount*.037)+mouseY, 4+5*sin(frameCount*.038), 4+5*sin(frameCount*.038));
  ellipse(120, 320+2*sin(frameCount*.025)+mouseY, 4+5*sin(frameCount*.022), 4+5*sin(frameCount*.022));

  //draw YELLOW CENTER of floating sparkles (middle plane)
  //bobs in tandem with GLOW
  fill(246, 244, 145);
  ellipse(20, 300+3*sin(frameCount*.035)+mouseY, 3, 3);
  ellipse(240, 300+4*sin(frameCount*.037)+mouseY, 4, 4);
  ellipse(120, 320+2*sin(frameCount*.025)+mouseY, 4, 4);

  //draw casted light (from moon)
  //light expands slightly according to frameCount changes
  fill(255, 70);
  quad(mouseY+80, mouseY+50, 405+2*sin(frameCount*.05), 270, 400, 400, 130, 405+5*sin(frameCount*.05));
  
  //draw bush (front, left)
  fill(120, 66, 66);
  quad(0, 320, 20, 340, 20, 400, 0, 400);
  rect(20, 340, 60, 400);
  quad(60, 360, 60, 400, 90, 400, 90, 385);
  quad(90, 385, 90, 400, 120, 400, 110, 390);

  //draw bush (front, right)
  fill(120, 66, 66);
  quad(400, 330, 400, 400, 370, 400, 370, 340);
  quad(360, 400, 370, 400, 370, 340, 360, 375);
  quad(360, 375, 360, 400, 290, 400, 320, 380);

  //draw plant
  fill(52, 83, 88);
  triangle(330, 340, 340, 340, 320, 360);
  triangle(300, 310, 310, 310, 320, 360);
  triangle(315, 340, 300, 330, 290, 330);
  quad(310, 310, 300, 310, 280, 300, 270, 280);
  triangle(310, 310, 310, 280, 300, 290);
  triangle(320, 360, 320, 280, 332, 260);
  quad(320, 320, 320, 330, 350, 315, 350, 310);
  triangle(350, 315, 360, 290, 350, 310);
  triangle(320, 290, 300, 250, 310, 240);
  triangle(305, 260, 310, 200, 310, 250);
  triangle(330, 270, 330, 240, 340, 220);
  triangle(330, 260, 350, 240, 360, 240);
  triangle(325, 300, 350, 280, 340, 280);
  quad(340, 280, 360, 280, 370, 270, 360, 270);
  triangle(360, 270, 370, 250, 370, 270);

  //draw left flower
  //opacity for all flowers change according to Y axis; disappears during "night"
  fill(237, 176, 219, mouseY);
  triangle(280, 290, 280, 280, 290, 280);
  triangle(280, 290, 280, 300, 290, 300);
  quad(280, 290, 270, 295, 260, 290, 270, 285);

  //draw top flower
  quad(305, 230, 310, 220, 320, 220, 320, 225);
  triangle(305, 230, 300, 215, 290, 220);
  triangle(305, 230, 300, 230, 300, 240);
  triangle(305, 230, 320, 230, 320, 240);

  //draw right flower
  triangle(360, 270, 360, 260, 350, 260);
  triangle(360, 270, 350, 270, 350, 280);
  triangle(360, 270, 365, 260, 370, 265);
  quad(360, 270, 370, 275, 370, 280, 365, 280);

  //draw bottom flower
  triangle(340, 320, 350, 320, 350, 330);
  triangle(340, 320, 340, 330, 335, 330);
  triangle(340, 320, 330, 320, 335, 315);
  triangle(340, 320, 340, 310, 350, 310);

  //draw flowerbuds
  ellipse(300, 250, 8, 8);
  ellipse(310, 290, 9, 9);
  ellipse(300, 320, 7, 7);
  ellipse(335, 260, 6, 6);
  ellipse(350, 240, 5, 5);
  ellipse(340, 290, 5, 5);  
  
  //GLOW of floating sparkles (front)
  //will pulse slowly
  //bobs up and down at different rates
  fill(255, 95);
  ellipse(40, 370+4*sin(frameCount*.02)+mouseY, 2+5*sin(frameCount*.036), 2+5*sin(frameCount*.036));
  ellipse(380, 360+3*sin(frameCount*.03)+mouseY, 3+5*sin(frameCount*.039), 3+5*sin(frameCount*.039));

  //YELLOW CENTER of floating sparkles (front)
  //bobs in tandem with GLOW
  fill(246, 244, 145);
  ellipse(40, 370+4*sin(frameCount*.02)+mouseY, 2, 2);
  ellipse(380, 360+3*sin(frameCount*.03)+mouseY, 3, 3);


      //FAIRY

  //Draw WHITE wings (underbase, left)
  fill(255, 90);
  triangle(125, 115, 125, 145, 190, 190);
  triangle(130, 175, 80, 190, 180, 200);
  triangle(190, 210, 140, 275, 145, 235);

  //Draw WHITE wings (underbase, right)
  quad(220, 185, 250, 145, 290, 120, 260, 160);
  quad(225, 195, 250, 185, 310, 185, 250, 200);
  triangle(220, 210, 230, 240, 280, 275);

  //Draw ORANGE wings (overlay, left)
  //opacity changes, allowing the color to fade in and out
  //varied formula for opacity, making wings change color at different rates
  fill(252, 134, 82, 100+60*sin(frameCount*.05));
  triangle(125, 115, 125, 145, 190, 190);
  fill(252, 134, 82, 100+60*sin(frameCount*.045));
  triangle(130, 175, 80, 190, 180, 200);
  fill(252, 134, 82, 100+60*sin(frameCount*.03));
  triangle(190, 210, 140, 275, 145, 235);
  
  //ORANGE OVERLAY wings (right)
  fill(252, 134, 82, 100+60*sin(frameCount*.038));
  quad(220, 185, 250, 145, 290, 120, 260, 160);
  fill(252, 134, 82, 100+60*sin(frameCount*.06));
  quad(225, 195, 250, 185, 310, 185, 250, 200);
  fill(252, 134, 82, 100+60*sin(frameCount*.055));
  triangle(220, 210, 230, 240, 280, 275);


      //BODY

  //draw back leg (thigh, calf, foot)
  fill(50, 41, 48);
  triangle(190, 260, 230, 260, 190, 360);
  triangle(190, 360, 180, 340, 140, 360);
  triangle(140, 360, 120, 345, 90, 360);

  //draw front leg (thigh, calf, foot)
  fill(60, 48, 60);
  triangle(210, 250, 175, 275, 240, 360);
  quad(150, 360, 190, 340, 230, 345, 240, 360);
  triangle(160, 360, 110, 360, 140, 350);

  //draw left arm
  triangle(185, 185, 140, 235, 190, 195);
  triangle(140, 235, 125, 190, 155, 220);

  //draw left hand
  quad(120, 210, 120, 190, 125, 190, 125, 200);
  triangle(100, 200, 120, 200, 120, 190);
  triangle(90, 210, 100, 200, 110, 200);

  //draw right arm
  triangle(230, 220, 245, 215, 270, 250);
  quad(270, 250, 260, 240, 275, 190, 280, 180);
  quad(135, 200, 130, 200, 120, 190, 125, 190);

  //draw right hand
  triangle(305, 170, 295, 180, 300, 180);
  quad(275, 190, 275, 185, 280, 180, 300, 180);

  //draw chest
  quad(240, 210, 230, 190, 180, 190, 210, 230);
  quad(230, 190, 235, 195, 235, 200, 230, 200);
  rect(215, 175, 205, 190);

  //draw face
  fill(60, 48, 60);
  quad(215, 190, 185, 175, 180, 130, 215, 130);
  quad(215, 175, 225, 180, 240, 140, 180, 140);
  rect(185, 130, 240, 140);
  triangle(235, 165, 220, 130, 220, 165);
  rect(165, 150, 220, 160);

  //draw eye - GREEN
  fill(118, 165, 116);
  triangle(230, 155, 225, 155, 230, 160);
  
  //draw eye - WHITE
  //opacity changes according to mouseX, creating gradient between layered objects
  fill(230, mouseX);
  triangle(230, 155, 225, 155, 230, 160);
   
  //draw clothes
  fill(75, 65, 62);
  quad(230, 220, 215, 270, 210, 250, 215, 235);
  quad(180, 250, 175, 275, 210, 250, 215, 235);
  quad(215, 270, 210, 250, 215, 235, 230, 260);
  quad(200, 220, 215, 205, 230, 220, 220, 240);
  quad(220, 235, 225, 235, 230, 250, 220, 250);
  rect(220, 250, 230, 260);
  triangle(235, 205, 245, 215, 210, 230);

  //draw hair
  fill(159, 79, 82);
  quad(165, 150, 165, 135, 230, 135, 210, 150);
  quad(165, 135, 180, 120, 250, 120, 250, 140);
  quad(180, 110, 180, 120, 250, 120, 240, 110);
  triangle(180, 110, 200, 105, 210, 110);
  quad(210, 110, 220, 105, 225, 105, 230, 110);
  quad(250, 140, 220, 130, 235, 150, 250, 145);
  triangle(215, 155, 200, 150, 210, 150);
  quad(165, 160, 165, 150, 200, 160, 180, 170);
  quad(165, 160, 200, 160, 205, 165, 205, 195);
  quad(165, 160, 200, 160, 200, 180, 180, 180);
  quad(180, 180, 175, 190, 205, 190, 205, 180);
  triangle(175, 190, 210, 190, 205, 195);
  triangle(200, 210, 205, 190, 210, 190);

  //YELLOW orb in Fairy's hand
  //width fluxes, making it look as if its spinning
  //bobs up and down
  fill(255, 252, 48, 80);
  ellipse(290, 165+5*sin(frameCount*.05), 10 + 5*sin(frameCount*.07), 15);
  fill(255, 252, 48);
  ellipse(290, 165+5*sin(frameCount*.05), 8 + 2*sin(frameCount*.07), 8);

  //WHITE orb
  //opacity increases as mouse moves rightwards
  //orb seemingly changes color according to horizontal mouse position
  fill(255, 80);
  ellipse(290, 165+5*sin(frameCount*.05), 10 + 5*sin(frameCount*.07), 10);
  fill(255, mouseX);
  ellipse(290, 165+5*sin(frameCount*.05), 8 + 2*sin(frameCount*.07), 8);
}