/* Title: A Summer Clocktower * Name: Adam Gill * Student ID: 991471378 * Class Code: PROG 14998 * */ void setup() { size(400, 400); } void draw() { rectMode(CENTER); ellipseMode(CENTER); // Sky background(135, 206, 250); //// Sun (uses equasion to move across the sky and pulsates) stroke(255, 185, 0); strokeWeight(3); fill(255, 255, 0); // Center ellipse(mouseX, (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60), 40 + sin(frameCount / 10.0), 40 + sin(frameCount / 10.0)); // --Triangles-- /* I apologize for the size of these lines, the main thing is that there are two equasions applied to them, * 1. A parabola equasion along the lines of: 2(0.02(x - 200))^2 + 60 where x is mouseX * 2. A sine function along the lines of: sin(x / 10) where x is frameCount */ strokeWeight(1); // Top triangle(mouseX + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) - (40 + sin(frameCount / 10.0)), mouseX - (5 + sin(frameCount / 10.0)), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) - (25 + sin(frameCount / 10.0)), mouseX + 5 + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) - (25 + sin(frameCount / 10.0))); // Top Right triangle(mouseX + 30 + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) - 30, mouseX + 15 + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) - (25 + sin(frameCount / 10.0)), mouseX + 25 + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) - (15 + sin(frameCount / 10.0))); // Right triangle(mouseX + 40 + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60), mouseX + 25 + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) - (5 + sin(frameCount / 10.0)), mouseX + 25 + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) + 5 + sin(frameCount / 10.0)); // Bot Right triangle(mouseX + 30 + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) + 30 + sin(frameCount / 10.0), mouseX + 15 + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) + 25 + sin(frameCount / 10.0), mouseX + 25 + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) + 15 + sin(frameCount / 10.0)); // Left triangle(mouseX - (40 + sin(frameCount / 10.0)), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60), mouseX - (25 + sin(frameCount / 10.0)), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) - (5 + sin(frameCount / 10.0)), mouseX - (25 + sin(frameCount / 10.0)), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) + 5 + sin(frameCount / 10.0)); // Bot Left triangle(mouseX - (30 + sin(frameCount / 10.0)), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) + 30 + sin(frameCount / 10.0), mouseX - (15 + sin(frameCount / 10.0)), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) + 25 + sin(frameCount / 10.0), mouseX - (25 + sin(frameCount / 10.0)), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) + 15 + sin(frameCount / 10.0)); // Bottom triangle(mouseX + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) + 40 + sin(frameCount / 10.0), mouseX - (5 + sin(frameCount / 10.0)), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) + 25 + sin(frameCount / 10.0), mouseX + 5 + sin(frameCount / 10.0), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) + 25 + sin(frameCount / 10.0)); // Top Left triangle(mouseX - (30 + sin(frameCount / 10.0)), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) - (30 + sin(frameCount / 10.0)), mouseX - (15 + sin(frameCount / 10.0)), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) - (25 + sin(frameCount / 10.0)), mouseX - (25 + sin(frameCount / 10.0)), (2 * ((0.02 * (mouseX - 200)) * (0.02 * (mouseX - 200))) + 60) - (15 + sin(frameCount / 10.0))); //// Clouds (sways gently) // Cloud 1 stroke(200); strokeWeight(3); fill(245); ellipse(25 * sin(frameCount / 50.0) + 80, 40, 40, 40); noStroke(); rect(25 * sin(frameCount / 50.0) + 80, 60, 40, 40); stroke(200); arc(25 * sin(frameCount / 50.0) + 60, 60, 40, 40, HALF_PI, (13 * PI) / 8); arc(25 * sin(frameCount / 50.0) + 100, 60, 40, 40, (11 * PI) / 8, TWO_PI + HALF_PI); line(25 * sin(frameCount / 50.0) + 60, 80, 25 * sin(frameCount / 50.0) + 100, 80); // Cloud 2 stroke(200); strokeWeight(3); fill(245); ellipse(25 * cos(frameCount / 50.0) + 240, 80, 40, 40); noStroke(); rect(25 * cos(frameCount / 50.0) + 240, 100, 40, 40); stroke(200); arc(25 * cos(frameCount / 50.0) + 220, 100, 40, 40, HALF_PI, (13 * PI) / 8); arc(25 * cos(frameCount / 50.0) + 260, 100, 40, 40, (11 * PI) / 8, TWO_PI + HALF_PI); line(25 * cos(frameCount / 50.0) + 220, 120, 25 * cos(frameCount / 50.0) + 260, 120); //// Hills (parallaxing effect) // Hills Far stroke(102, 142, 84); strokeWeight(3); fill(84, 156, 48); arc(120 + ((mouseX - 200) * 0.05), height - 40, 280, 180, PI, TWO_PI); arc(width - 20 + ((mouseX - 200) * 0.075), height - 40, 120, 120, PI, TWO_PI); // Filler Far noStroke(); rectMode(CORNERS); rect(0, height - 80, width, height); // Hills Med stroke(102, 142, 84); strokeWeight(3); fill(105, 195, 60); arc(width - 120 + ((mouseX - 200) * 0.1), height, 300, 240, PI, TWO_PI); arc(40 + ((mouseX - 200) * 0.125), height - 20, 240, 160, PI, TWO_PI); // Filler Med noStroke(); rect(0, height - 40, width, height); // Hills Close stroke(102, 142, 84); strokeWeight(3); fill(135, 207, 99); arc(40 + ((mouseX - 200) * 0.2), height, 180, 80, PI, TWO_PI); arc(width - 20 + ((mouseX - 200) * 0.2), height, 140, 80, PI, TWO_PI); arc(width / 2 + ((mouseX - 200) * 0.225), height + 20, 280, 140, PI, TWO_PI); //// Trees (attached to hills) // Tree 1 Trunk stroke(78, 51, 25); strokeWeight(2); fill(117, 77, 38); rectMode(CENTER); triangle(80 + ((mouseX - 200) * 0.05), height - 140, 60 + ((mouseX - 200) * 0.05), height - 120, 100 + ((mouseX - 200) * 0.05), height - 120); noStroke(); rect(80 + ((mouseX - 200) * 0.05), height - 160, 20, 78); stroke(78, 51, 25); line(70 + ((mouseX - 200) * 0.05), height / 2, 70 + ((mouseX - 200) * 0.05), height / 2 + 72); line(90 + ((mouseX - 200) * 0.05), height / 2, 90 + ((mouseX - 200) * 0.05), height / 2 + 72); fill(20, 13, 6); stroke(0); ellipse(85 + ((mouseX - 200) * 0.05), height - 150, 10, 20); // Tree 1 Leaves stroke(51, 77, 25); strokeWeight(3); fill(77, 115, 38); ellipse(80 + ((mouseX - 200) * 0.05), height / 2 - 20, 40, 40); noStroke(); rect(80 + ((mouseX - 200) * 0.05), height / 2, 40, 40); stroke(51, 77, 25); arc(60 + ((mouseX - 200) * 0.05), height / 2, 40, 40, HALF_PI, (13 * PI) / 8); arc(100 + ((mouseX - 200) * 0.05), height / 2, 40, 40, (11 * PI) / 8, TWO_PI + HALF_PI); line(60 + ((mouseX - 200) * 0.05), height / 2 + 20, 100 + ((mouseX - 200) * 0.05), height / 2 + 20); // Tree 2 Trunk stroke(78, 51, 25); strokeWeight(2); fill(117, 77, 38); triangle(160 + ((mouseX - 200) * 0.05), height - 130, 140 + ((mouseX - 200) * 0.05), height - 110, 180 + ((mouseX - 200) * 0.05), height - 110); noStroke(); rect(160 + ((mouseX - 200) * 0.05), height - 150, 20, 78); stroke(78, 51, 25); line(150 + ((mouseX - 200) * 0.05), height / 2 + 10, 150 + ((mouseX - 200) * 0.05), height / 2 + 82); line(170 + ((mouseX - 200) * 0.05), height / 2 + 10, 170 + ((mouseX - 200) * 0.05), height / 2 + 82); fill(20, 13, 6); stroke(0); ellipse(155 + ((mouseX - 200) * 0.05), height - 140, 10, 20); // Tree 2 Leaves stroke(51, 77, 25); strokeWeight(3); fill(77, 115, 38); ellipse(160 + ((mouseX - 200) * 0.05), height / 2 - 10, 40, 40); noStroke(); rect(160 + ((mouseX - 200) * 0.05), height / 2 + 10, 40, 40); stroke(51, 77, 25); arc(140 + ((mouseX - 200) * 0.05), height / 2 + 10, 40, 40, HALF_PI, (13 * PI) / 8); arc(180 + ((mouseX - 200) * 0.05), height / 2 + 10, 40, 40, (11 * PI) / 8, TWO_PI + HALF_PI); line(140 + ((mouseX - 200) * 0.05), height / 2 + 30, 180 + ((mouseX - 200) * 0.05), height / 2 + 30); //// Clock Tower (attached to hills) // Building stroke(116, 38, 38); strokeWeight(2); fill(155, 49, 49); rect(width - 100 + ((mouseX - 200) * 0.1), height / 2 + 70, 80, 60); // Roof stroke(82, 82, 122); fill(102, 102, 153); quad(width - 150 + ((mouseX - 200) * 0.1), height / 2 + 40, width - 120 + ((mouseX - 200) * 0.1), height / 2 + 20, width - 80 + ((mouseX - 200) * 0.1), height / 2 + 20, width - 50 + ((mouseX - 200) * 0.1), height / 2 + 40); // Tower stroke(116, 38, 38); strokeWeight(1); fill(155, 49, 49); rectMode(CORNER); rect(width - 120 + ((mouseX - 200) * 0.1), height / 2 - 20, 5, 40); rect(width - 85 + ((mouseX - 200) * 0.1), height / 2 - 20, 5, 40); stroke(82, 82, 122); strokeWeight(2); fill(102, 102, 153); triangle(width - 100 + ((mouseX - 200) * 0.1), height / 2 - 40, width - 125 + ((mouseX - 200) * 0.1), height / 2 - 20, width - 75 + ((mouseX - 200) * 0.1), height / 2 - 20); // Bell stroke(223, 128, 32); fill(223, 223, 32); ellipseMode(CORNER); ellipse(width - 102.5 + ((mouseX - 200) * 0.1), height / 2 - 17.5, 5, 5); triangle(width - 100 + ((mouseX - 200) * 0.1), height / 2 - 5, width - 111 + ((mouseX - 200) * 0.1), height / 2 + 10, width - 89 + ((mouseX - 200) * 0.1), height / 2 + 10); rectMode(CENTER); noStroke(); rect(width - 100 + ((mouseX - 200) * 0.1), height / 2, 16, 16); ellipseMode(CENTER); stroke(223, 128, 32); arc(width - 100 + ((mouseX - 200) * 0.1), height / 2 - 8, 16, 8, PI, TWO_PI); line(width - 108 + ((mouseX - 200) * 0.1), height / 2 - 8, width - 108 + ((mouseX - 200) * 0.1), height / 2 + 5); line(width - 92 + ((mouseX - 200) * 0.1), height / 2 - 8, width - 92 + ((mouseX - 200) * 0.1), height / 2 + 5); arc(width - 100 + ((mouseX - 200) * 0.1), height / 2 + 10, 4, 4, 0, PI); // Clock (Moves at real time) // Face stroke(0); strokeWeight(1.5); fill(255); ellipse(width - 100 + ((mouseX - 200) * 0.1), height / 2 + 25, 20, 20); // Second Hand strokeWeight(1); line(width - 100 + ((mouseX - 200) * 0.1), height / 2 + 25, width - 100 + ((mouseX - 200) * 0.1) + (7 * sin(millis() * (TAU / 60000.0))), height / 2 + 25 + (-7 * cos(millis() * (TAU / 60000.0)))); // Minute Hand strokeWeight(1.5); line(width - 100 + ((mouseX - 200) * 0.1), height / 2 + 25, width - 100 + ((mouseX - 200) * 0.1) + (7 * sin(millis() * (TAU / 3600000.0))), height / 2 + 25 + (-7 * cos(millis() * (TAU / 3600000.0)))); // Hour Hand line(width - 100 + ((mouseX - 200) * 0.1), height / 2 + 25, width - 100 + ((mouseX - 200) * 0.1) + (4 * sin(millis() * (TAU / 43200000.0))), height / 2 + 25 + (-4 * cos(millis() * (TAU / 43200000.0)))); // Windows stroke(0); strokeWeight(2); fill(126, 164, 206); // Window 1 rect(width - 120 + ((mouseX - 200) * 0.1), height / 2 + 60, 20, 20); line(width - 120 + ((mouseX - 200) * 0.1), height / 2 + 50, width - 120 + ((mouseX - 200) * 0.1), height / 2 + 70); line(width - 130 + ((mouseX - 200) * 0.1), height / 2 + 60, width - 110 + ((mouseX - 200) * 0.1), height / 2 + 60); // Window 2 rect(width - 80 + ((mouseX - 200) * 0.1), height / 2 + 60, 20, 20); line(width - 80 + ((mouseX - 200) * 0.1), height / 2 + 50, width - 80 + ((mouseX - 200) * 0.1), height / 2 + 70); line(width - 90 + ((mouseX - 200) * 0.1), height / 2 + 60, width - 70 + ((mouseX - 200) * 0.1), height / 2 + 60); // Front Door noStroke(); fill(117, 77, 38); rect(width - 100 + ((mouseX - 200) * 0.1), height / 2 + 90, 20, 20); stroke(78, 51, 25); strokeWeight(2); arc(width - 100 + ((mouseX - 200) * 0.1), height / 2 + 80, 20, 20, PI, TWO_PI); line(width - 110 + ((mouseX - 200) * 0.1), height / 2 + 80, width - 110 + ((mouseX - 200) * 0.1), height / 2 + 100); line(width - 90 + ((mouseX - 200) * 0.1), height / 2 + 80, width - 90 + ((mouseX - 200) * 0.1), height / 2 + 100); line(width - 110 + ((mouseX - 200) * 0.1), height / 2 + 100, width - 90 + ((mouseX - 200) * 0.1), height / 2 + 100); stroke(255, 219, 77); strokeWeight(1); fill(255, 230, 128); ellipse(width - 95 + ((mouseX - 200) * 0.1), height / 2 + 90, 3, 3); //// Reset frameRate(60); } void mousePressed() { // Pause frameRate(1); // Bell Toll Effect stroke(223, 223, 32, 200); strokeWeight(4); noFill(); arc(width - 100 + ((mouseX - 200) * 0.1), height / 2, 50, 25, HALF_PI + QUARTER_PI, PI + QUARTER_PI); arc(width - 100 + ((mouseX - 200) * 0.1), height / 2, 50, 25, -QUARTER_PI, QUARTER_PI); arc(width - 100 + ((mouseX - 200) * 0.1), height / 2, 75, 30, HALF_PI + QUARTER_PI, PI + QUARTER_PI); arc(width - 100 + ((mouseX - 200) * 0.1), height / 2, 75, 30, -QUARTER_PI, QUARTER_PI); arc(width - 100 + ((mouseX - 200) * 0.1), height / 2, 100, 35, HALF_PI + QUARTER_PI, PI + QUARTER_PI); arc(width - 100 + ((mouseX - 200) * 0.1), height / 2, 100, 35, -QUARTER_PI, QUARTER_PI); }