/*
"The Moon Moves Sideways"
by Carsten Booth
Sept 18th 2017
Intro to Media Computation
Instructor: Nicolas Hesler
Interactive Drawing
Interactions:
Moon position changes based on position of mouseX, as well as opacity of tree outline, and position of bottom vertices of tree shadows.
Clicking the mouse will briefly add snow to many of the trees, and will output a line of text.
*/
void setup() {
size(400, 400);
}
void draw() {
rectMode(CORNERS);
noStroke();
frameRate(60);
//set background to DARK BLUE
background(18, 31, 61);
//set colour to LIGHT BLUE
fill(60, 95, 175);
//moon
ellipse(mouseX*3, mouseX*1.2+64, 64, 64);
//background hill
fill(102);
quad(-1, 234, 182, 234, 196, 248, -1, 420);
fill(205);
beginShape();
vertex(-1, 180);
vertex(105, 209);
vertex(154, 215);
vertex(182, 234);
vertex(115, 250);
vertex(-9, 272);
endShape();
//background tree highlights
strokeWeight(4);
strokeCap(ROUND);
//first tree highlights
stroke(60, 95, 175, 255-mouseX*3.2);
line(-15, 174, 39, 48);
line(39, 47, 66, -2);
stroke(60, 95, 175, 255-mouseX*3);
line(-15, 186, 32, 77);
line(32, 76, 69, -2);
//second tree highlights
stroke(60, 95, 175, 255-mouseX*2.8);
line(55, 194, 90, -2);
stroke(60, 95, 175, 255-mouseX*2.6);
line(59, 195, 94, -2);
//third tree highlights
stroke(60, 95, 175, 255-mouseX*2.4);
line(101, 209, 101, 110);
line(101, 108, 100, 69);
line(100, 68, 102, 16);
line(102, 15, 105, -1);
stroke(60, 95, 175, 255-mouseX*2.2);
line(105, 210, 106, 122);
line(106, 121, 105, 69);
line(105, 68, 108, -1);
//fourth tree highlights
stroke(60, 95, 175, 255-mouseX*2);
line(149, 213, 151, 179);
line(150, 177, 161, 80);
line(161, 79, 166, -2);
stroke(60, 95, 175, 255-mouseX*1.8);
line(154, 202, 156, 177);
line(156, 175, 170, 52);
line(170, 50, 171, -2);
//fifth tree highlights
stroke(60, 95, 175, 255-mouseX*1.6);
line(156, 201, 169, 145);
line(168, 145, 190, 80);
line(190, 78, 212, -2);
stroke(60, 95, 175, 255-mouseX*1.4);
line(156, 217, 170, 166);
line(170, 165, 193, 89);
line(193, 88, 218, -2);
//midground tree highlights
//fifth tree highlights
stroke(60, 95, 175, -90+mouseX);
line(408, 181, 389, 138);
line(376, 109, 354, 59);
line(343, 37, 328, -3);
stroke(60, 95, 175, -80+mouseX);
line(322, -2, 342, 50);
line(353, 78, 377, 128);
line(392, 165, 408, 218);
//fourth tree highlights
stroke(60, 95, 175, -70+mouseX);
line(395, 291, 391, 170);
line(389, 136, 389, -3);
stroke(60, 95, 175, -60+mouseX);
line(379, 288, 377, 131);
line(378, 107, 380, -3);
//third tree highlights
stroke(60, 95, 175, -60+mouseX);
line(356, 276, 354, 235);
line(354, 233, 357, 202);
line(357, 202, 354, 95);
line(354, 94, 352, 79);
line(352, 76, 355, 38);
line(355, 36, 356, -2);
stroke(60, 95, 175, -50+mouseX);
line(346, -2, 344, 37);
line(342, 54, 341, 69);
line(341, 70, 339, 172);
line(340, 170, 330, 148);
line(330, 146, 320, 93);
line(320, 92, 316, 79);
line(316, 78, 306, 54);
line(306, 52, 298, -2);
stroke(60, 95, 175, -40+mouseX);
line(294, -2, 301, 59);
line(301, 60, 302, 63);
line(308, 79, 312, 90);
line(312, 91, 322, 148);
line(322, 149, 333, 189);
line(333, 190, 335, 210);
line(335, 211, 334, 270);
//second tree highlights
stroke(60, 95, 175, -30+mouseX);
line(310, 268, 308, 157);
line(308, 255, 308, 190);
line(308, 188, 306, 183);
line(306, 181, 308, 143);
line(308, 141, 307, 90);
line(307, 88, 307, 78);
line(308, 56, 310, -2);
stroke(60, 95, 175, -20+mouseX);
line(303, 264, 302, 190);
line(302, 190, 303, 66);
line(305, 38, 307, -2);
//first tree highlights
stroke(60, 95, 175, -10+mouseX);
line(274, 268, 270, 133);
line(270, 131, 273, 8);
line(273, 6, 270, -4);
stroke(60, 95, 175, 0+mouseX);
line(264, 270, 264, 130);
line(264, 128, 267, -2);
noStroke();
//background tree shadows
fill(0, 240);
//second tree shadow
beginShape();
vertex(55, 196);
vertex(57, 199);
vertex(59, 198);
vertex(-mouseX*6+160, 400);
vertex(-mouseX*6+150, 400);
endShape();
//third tree shadow
beginShape();
vertex(101, 210);
vertex(103, 211);
vertex(105, 211);
vertex(-mouseX*6+280, 400);
vertex(-mouseX*6+265, 400);
endShape();
//fourth tree shadow
beginShape();
vertex(150, 215);
vertex(151, 210);
vertex(155, 218);
vertex(-mouseX*6+310, 400);
vertex(-mouseX*6+300, 400);
endShape();
//fifth tree shadow
beginShape();
vertex(152, 218);
vertex(155, 218);
vertex(158, 219);
vertex(-mouseX*6+370, 400);
vertex(-mouseX*6+360, 400);
endShape();
//background forest; titles are ordered by number from left first to right last
fill(0);
//first tree
beginShape();
vertex(-15, 174);
vertex(39, 48);
vertex(66, -2);
vertex(69, -2);
vertex(32, 77);
vertex(-15, 186);
endShape();
//second tree
beginShape();
vertex(55, 196);
vertex(73, 92);
vertex(90, -1);
vertex(94, -1);
vertex(69, 147);
vertex(59, 198);
vertex(57, 200);
endShape();
//third tree
beginShape();
vertex(101, 210);
vertex(101, 110);
vertex(100, 69);
vertex(102, 17);
vertex(105, -1);
vertex(108, -1);
vertex(107, 18);
vertex(105, 69);
vertex(106, 122);
vertex(105, 211);
vertex(103, 212);
endShape();
//fourth tree
beginShape();
vertex(150, 215);
vertex(152, 177);
vertex(161, 80);
vertex(166, -2);
vertex(171, -2);
vertex(170, 52);
vertex(156, 177);
vertex(155, 218);
vertex(151, 219);
endShape();
//fifth tree
beginShape();
vertex(152, 218);
vertex(169, 146);
vertex(190, 79);
vertex(213, -2);
vertex(219, -2);
vertex(193, 89);
vertex(169, 166);
vertex(159, 219);
vertex(155, 220);
endShape();
//midground hill
fill(77);
quad(208, 290, 258, 270, 432, 334, 375, 462);
fill(180);
beginShape();
vertex(258, 270);
vertex(318, 265);
vertex(432, 302);
vertex(432, 334);
vertex(341, 328);
endShape();
//midground tree shadows, bottom vertices change based on position of mouseX
fill(0, 200);
//first tree Shadow
beginShape();
vertex(265, 272);
vertex(270, 272);
vertex(274, 270);
vertex(274, 272);
vertex(-mouseX*3+430, 428);
vertex(-mouseX*3+415, 428);
endShape();
//second tree shadow
beginShape();
vertex(303, 267);
vertex(311, 268);
vertex(311, 270);
vertex(-mouseX*3+480, 428);
vertex(-mouseX*3+465, 428);
endShape();
//third tree shadow
beginShape();
vertex(334, 272);
vertex(356, 278);
vertex(356, 279);
vertex(-mouseX*3+520, 428);
vertex(-mouseX*3+500, 428);
endShape();
//fourth tree shadow
beginShape();
vertex(379, 288);
vertex(398, 299);
vertex(398, 300);
vertex(-mouseX*3+550, 428);
vertex(-mouseX*3+535, 428);
vertex(379, 290);
endShape();
//midground hill Forest; trees are ordered from left first to right last
fill(0);
//first tree
beginShape();
vertex(264, 272);
vertex(266, 175);
vertex(265, 130);
vertex(269, 4);
vertex(268, -2);
vertex(270, -4);
vertex(273, 8);
vertex(271, 37);
vertex(270, 133);
vertex(271, 213);
vertex(274, 270);
vertex(270, 274);
endShape();
//second tree
beginShape();
vertex(303, 268);
vertex(304, 259);
vertex(303, 194);
vertex(303, 190);
vertex(304, 142);
vertex(303, 80);
vertex(307, -2);
vertex(310, -2);
vertex(307, 90);
vertex(308, 143);
vertex(307, 183);
vertex(308, 190);
vertex(309, 257);
vertex(311, 268);
vertex(307, 270);
endShape();
//third tree
beginShape();
vertex(334, 272);
vertex(335, 210);
vertex(333, 189);
vertex(322, 148);
vertex(313, 90);
vertex(301, 59);
vertex(294, -2);
vertex(299, -2);
vertex(307, 54);
vertex(316, 79);
vertex(321, 94);
vertex(330, 148);
vertex(339, 172);
vertex(340, 143);
vertex(341, 70);
vertex(346, 22);
vertex(346, -1);
vertex(356, -2);
vertex(357, 9);
vertex(355, 38);
vertex(352, 79);
vertex(354, 96);
vertex(357, 203);
vertex(354, 235);
vertex(356, 278);
vertex(345, 278);
endShape();
//fourth tree
beginShape();
vertex(379, 288);
vertex(378, 211);
vertex(378, 164);
vertex(377, 131);
vertex(379, 36);
vertex(381, -3);
vertex(389, -3);
vertex(389, 145);
vertex(391, 170);
vertex(395, 273);
vertex(398, 299);
vertex(389, 298);
endShape();
//fifth tree
beginShape();
vertex(408, 218);
vertex(394, 168);
vertex(360, 91);
vertex(347, 63);
vertex(321, -3);
vertex(328, -3);
vertex(347, 49);
vertex(367, 84);
vertex(408, 181);
endShape();
//foreground hill
fill(50, 50, 50);
quad(-8, 325, 285, 315, 340, 417, -10, 417);
fill(152);
beginShape();
vertex(-8, 300);
vertex(84, 280);
vertex(200, 243);
vertex(238, 250);
vertex(285, 315);
vertex(280, 324);
vertex(201, 384);
vertex(90, 332);
vertex(-8, 325);
endShape();
fill(0, 0, 0, 75);
}
//when the mouse is pressed, draw snow on trees and output a line of text
void mousePressed () {
frameRate(1);
println("It was freezing cold that night, and you were all alone.");
//snow on trees, shapes ordered from left to right, descending
fill(242);
triangle(11, 111, 40, 43, 63, 5);
triangle(70, 107, 80, 52, 85, 29);
triangle(103, -2, 106, -3, 102, 17);
quad(155, 190, 157, 190, 159, 189, 155, 204);
triangle(306, 183, 308, 188, 307, 190);
quad(329, 146, 337, 158, 340, 146, 339, 173);
triangle(355, 63, 365, 80, 376, 107);
triangle(390, 141, 404, 167, 402, 171);
}