Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/*Rosy Forest by Jessica Olesky
 Move your mouse to change the time of day, and watch as the shadows change size
 */


void setup() {
  //set up canvas
  size(400, 400);
}

void draw() {
  //set up background 
  background(215, 228, 247);


  //set sun with glow
  noStroke();
  fill(255, 250, 180);
  ellipseMode(CENTER);
  ellipse(200, mouseY, 60, 60);
  fill(232, 195, 107, mouseY/2);
  ellipse(200, mouseY, 400, 400);
  rectMode(CORNERS);


  //mountain #2
  fill(109, 164, 166);
  triangle(270, 100, 290, 140, 220, 170);
  triangle(270, 100, 220, 170, 250, 100);
  triangle(250, 100, 230, 110, 220, 170);
  triangle(230, 110, 219, 119, 220, 170);
  triangle(219, 119, 210, 118, 220, 170);
  triangle(210, 118, 220, 170, 200, 120);
  triangle(160, 160, 200, 120, 220, 170);

  //mountain #1
  fill(38, 104, 105);
  triangle(380, 140, 370, 120, 306, 150);
  triangle(370, 120, 360, 100, 306, 150);
  triangle(360, 100, 350, 80, 306, 150);
  triangle(350, 80, 340, 60, 306, 150);
  triangle(340, 60, 330, 63, 306, 150);
  triangle(330, 63, 320, 67, 306, 150);
  triangle(320, 67, 300, 50, 306, 150);
  triangle(300, 50, 294, 53, 306, 150);
  triangle(294, 53, 280, 72, 306, 150);
  triangle(280, 72, 262, 100, 306, 150);
  triangle(262, 100, 243, 140, 306, 150);
  triangle(243, 140, 230, 170, 306, 150);

  //mountain top
  fill(240);
  triangle(294, 53, 300, 70, 269, 90);
  triangle(300, 50, 294, 53, 300, 70);
  triangle(300, 50, 300, 70, 310, 60);
  triangle(310, 60, 300, 70, 340, 90);
  triangle(320, 67, 340, 60, 340, 90);

  //hill #5 TREES
  fill(0);
  triangle(20, 140, 23, 140, 20, 130);
  triangle(30, 140, 33, 140, 32, 130);
  triangle(35, 135, 40, 135, 37, 160);
  triangle(44, 140, 46, 140, 45, 124);

  //hill #5 TREES brush
  fill(45, 85, 102);
  triangle(33, 135, 42, 135, 37, 120);
  fill(195, 113, 119);
  ellipse(20, 128, 8, 8);
  fill(104, 28, 34);
  ellipse(24, 126, 3, 3);
  fill(86, 21, 33);
  ellipse(32, 130, 6, 6);
  fill(232, 178, 179);
  ellipse(30, 132, 3, 3);
  fill(232, 178, 179);
  ellipse(45, 124, 9, 9);

  //hill #5
  fill(224, 238, 156);
  triangle(0, 140, 0, 400, 80, 135);
  triangle(80, 135, 0, 400, 160, 150);
  triangle(160, 150, 0, 400, 220, 170);

  //hill #5 TREE shadows
  fill(0, 100);
  quad(20, 138, 23, 138, 3, 143+mouseY/30, 3, 143+mouseY/30);
  quad(30, 138, 33, 138, 9, 145+mouseY/30, 9, 145+mouseY/30);
  quad(35, 138, 40, 138, 17, 145+mouseY/30, 17, 145+mouseY/30);
  quad(44, 136, 47, 136, 23, 145+mouseY/30, 23, 145+mouseY/30);


  //mountain #2 shadow
  fill(0, 150);
  quad(169, 151, 220, 170, 230, 210+mouseY/30, 180, 160+mouseY/30);


  //hill #4 TREES
  fill(50, 35, 25);
  triangle(180, 172, 185, 172, 183, 152);
  fill(78, 54, 31);
  triangle(205, 170, 210, 170, 207, 146);
  triangle(215, 170, 220, 170, 218, 147);

  //hill #4 TREES brush
  fill(86, 21, 33);
  ellipse(183, 150, 17, 17);
  fill(133, 38, 50);
  ellipse(189, 155, 8, 8);
  fill(155, 73, 92);
  ellipse(178, 157, 7, 7);
  fill(137, 68, 84);
  ellipse(207, 140, 22, 22);
  fill(195, 113, 119);
  ellipse(197, 138, 10, 10);
  fill(232, 178, 179);
  ellipse(198, 141, 7, 7);
  fill(133, 38, 50);
  ellipse(218, 147, 15, 15);
  fill(155, 73, 92);
  ellipse(224, 150, 6, 6);

  //hill #4
  fill(200, 222, 100);
  triangle(400, 400, 340, 140, 400, 140);
  triangle(400, 400, 340, 140, 280, 150);
  triangle(400, 400, 280, 150, 200, 170);
  triangle(40, 180, 400, 400, 200, 170);

  //hill #4 Tree shadow
  fill(0, 100);
  quad(180, 170, 185, 170, 186, 185+mouseY/25, 173, 185+mouseY/25);
  quad(205, 168, 210, 166, 216, 189+mouseY/25, 199, 189+mouseY/25);
  quad(215, 165, 220, 164, 228, 185+mouseY/25, 218, 185+mouseY/25);


  //mountain shadow
  fill(57, 65, 30, 240);
  quad(235, 160, 380, 140, 380, 180+mouseY/30, 370, 185+mouseY/30);
  quad(320, 143, 380, 140, 390, 160+mouseY/30, 390, 160+mouseY/30);
  triangle(246, 158, 290, 145, 290, 160);
  triangle(380, 140, 320, 137, 320, 145);


  //hill #3 TREES
  fill(50, 35, 25);
  triangle(65, 177, 68, 177, 68, 140);
  triangle(68, 164, 68, 168, 57, 155);
  triangle(73, 169, 80, 169, 75, 220);
  triangle(99, 185, 102, 185, 102, 150);
  triangle(117, 187, 123, 189, 122, 132);
  triangle(122, 166, 122, 163, 140, 150);

  //hill #3 TREES brush
  fill(45, 85, 102);
  triangle(69, 169, 86, 169, 75, 120);
  fill(155, 73, 92);
  ellipse(70, 140, 35, 35);
  fill(115, 33, 43);
  ellipse(57, 155, 15, 15);
  fill(86, 21, 33);
  ellipse(78, 124, 12, 12);
  ellipse(103, 157, 20, 20);
  fill(195, 113, 119);
  ellipse(93, 155, 7, 7);
  fill(232, 178, 179);
  ellipse(122, 132, 40, 40);
  fill(133, 38, 50);
  ellipse(140, 150, 20, 20);
  fill(137, 68, 84);
  ellipse(141, 141, 12, 12);

  //hill #3
  fill(166, 192, 60);
  triangle(0, 180, 0, 300, 200, 400);
  triangle(0, 180, 40, 175, 200, 400);
  triangle(100, 180, 40, 175, 200, 400);
  triangle(100, 180, 140, 190, 200, 400);
  triangle(140, 190, 190, 210, 200, 400);
  triangle(220, 220, 190, 210, 200, 400);
  triangle(220, 220, 240, 220, 200, 400);
  triangle(240, 220, 280, 215, 200, 400);
  triangle(280, 215, 360, 220, 200, 400);
  triangle(360, 220, 200, 400, 400, 220);

  //hill #3 TREE shadows
  fill(0, 100);
  quad(65, 177, 68, 177, 40, 200+mouseY/30, 30, 200+mouseY/30);
  quad(73, 177, 80, 177, 65, 190+mouseY/30, 55, 190+mouseY/30);
  quad(99, 180, 102, 182, 94, 190+mouseY/30, 84, 190+mouseY/30);
  quad(117, 185, 123, 186, 119, 200+mouseY/30, 100, 200+mouseY/30);


  //hill #2 TREES
  fill(78, 54, 31);
  rectMode(CENTER);
  triangle(260, 235, 260, 285, 253, 285);
  triangle(260, 250, 260, 255, 238, 236);
  fill(50, 35, 25);
  triangle(310, 260, 320, 260, 315, 190);
  triangle(315, 225, 318, 230, 333, 203);
  fill(35, 30, 15);
  rect(293, 270, 12, 20);

  //hill #2 TREES
  ellipseMode(CENTER);
  fill(137, 68, 84);
  ellipse(260, 213, 60, 60);
  fill(195, 113, 119);
  ellipse(238, 236, 30, 30);
  fill(232, 178, 179);
  ellipse(233, 215, 20, 20);
  fill(86, 21, 33);
  ellipse(331, 150, 45, 45);
  fill(104, 28, 34);
  ellipse(311, 175, 75, 75);
  fill(133, 38, 50);
  ellipse(347, 200, 40, 40);
  fill(145, 53, 49);
  ellipse(333, 203, 30, 30);

  //hill #2
  fill(131, 155, 41);
  triangle(400, 215, 400, 400, 380, 220);
  triangle(380, 220, 340, 240, 400, 400);
  triangle(340, 240, 310, 260, 400, 400);
  triangle(310, 260, 290, 270, 400, 400);
  triangle(290, 270, 260, 280, 400, 400);
  triangle(260, 280, 400, 400, 220, 290);
  triangle(170, 310, 220, 290, 400, 400);

  //shadows
  fill(0, 100);
  quad(299, 265, 287, 270, 310, 300+mouseY/25, 350, 300+mouseY/25);
  quad(254, 280, 260, 280, 278, 290+mouseY/25, 262, 290+mouseY/25);
  quad(315, 257, 320, 250, 390, 290+mouseY/25, 360, 290+mouseY/25);

  //brush #3
  fill(45, 85, 102);
  triangle(268, 260, 316, 260, 290, 180);

  //hill #1
  fill(76, 102, 19);
  rectMode(CORNERS);
  rect(0, 390, 400, 400);
  triangle(0, 290, 40, 285, 0, 400);
  triangle(40, 285, 80, 280, 0, 400);
  triangle(80, 280, 120, 280, 0, 400);
  triangle(120, 280, 160, 285, 0, 400);
  triangle(160, 285, 190, 300, 0, 400);
  triangle(190, 300, 240, 320, 0, 400);
  triangle(300, 340, 240, 320, 0, 400);
  triangle(300, 340, 340, 360, 0, 400);
  triangle(400, 390, 340, 360, 0, 400);

  //set background to darken
  fill(0, mouseY/1.7);
  rect(0, 0, width, height);

  //PERSONAL NOTES
  //quad keep two points fixed on the object and the other points can move freely
  // building rect(40,60,80,250)
  // shadow quad(40,250,80,250,80,250+mouseY/2,40,250+mouse+/2)
  //fill(0 (colour), 150 (alpha))
  //new shadow (quad (40,250,80,250,140-mouseX,250+mouseY/2,100-mouseX,250+mouse+/2
  //apply treansparency to entire screen
  //fill(0,mouseY/2 (<- divided by two))
  //rect(0,0,displayWidth,displayHeight)
}