/* Interactive Drawing - Lightsaber By Matthew Burchat Started Project: 9/04/2018 Last Updated: 9/12/2018 Anakin Skywalker's Lightaber Interactions: If you move your mouse from left to right, you can see the background and blade change from blue to red. If you move your mouse from up to down, you can see the background and blade disappears as if the lightsaber is being turned off. If you press any mouse button, a blaster shot will be deflected off of the lightsaber noramlly used when the lightsaber is on Course: Introduction to Media Computation Professor: Nicolas Hesler */ void setup() { size(400, 400); background(255); } void draw() { frameRate(60); noStroke(); //println(mouseX, mouseY); // Background Gradient // Outside to Inside // Blue fill(32, 62, 249); quad(0, 0, 50, 0, 50, 400, 0, 400); quad(350, 0, 400, 0, 400, 400, 350, 400); fill(62, 138, 253); quad(50, 0, 100, 0, 100, 400, 50, 400); quad(300, 0, 350, 0, 350, 400, 300, 400); fill(88, 175, 253); quad(100, 0, 150, 0, 150, 400, 100, 400); quad(250, 0, 300, 0, 300, 400, 250, 400); fill(223, 252, 254); quad(150, 0, 250, 0, 250, 400, 150, 400); // red fill(219, 63, 51, mouseX/400.0*255); quad(0, 0, 50, 0, 50, 400, 0, 400); quad(350, 0, 400, 0, 400, 400, 350, 400); fill(248, 116, 129, mouseX/400.0*255); quad(50, 0, 100, 0, 100, 400, 50, 400); quad(300, 0, 350, 0, 350, 400, 300, 400); fill(250, 191, 193, mouseX/400.0*255); quad(100, 0, 150, 0, 150, 400, 100, 400); quad(250, 0, 300, 0, 300, 400, 250, 400); fill(255, 240, 240, mouseX/400.0*255); quad(150, 0, 250, 0, 250, 400, 150, 400); // Lightsaber blade, red than blue // Inside to outside noStroke(); // blue fill(223, 252, 254); quad(190, 0, 210, 0, 210, 148, 190, 148); fill(88, 175, 253); quad(185, 0, 190, 0, 190, 148, 185, 148); quad(210, 0, 215, 0, 215, 148, 210, 148); fill(62, 138, 253); quad(215, 0, 220, 0, 220, 148, 215, 148); quad(180, 0, 185, 0, 185, 148, 180, 148); fill(32, 62, 249); quad(175, 0, 180, 0, 180, 148, 175, 148); quad(220, 0, 225, 0, 225, 148, 220, 148); // red fill(255, 240, 240, mouseX/400.0*255); quad(190, 0, 210, 0, 210, 148, 190, 148); fill(250, 191, 193, mouseX/400.0*255); quad(185, 0, 190, 0, 190, 148, 185, 148); quad(210, 0, 215, 0, 215, 148, 210, 148); fill(248, 116, 129, mouseX/400.0*255); quad(215, 0, 220, 0, 220, 148, 215, 148); quad(180, 0, 185, 0, 185, 148, 180, 148); fill(219, 63, 51, mouseX/400.0*255); quad(175, 0, 180, 0, 180, 148, 175, 148); quad(220, 0, 225, 0, 225, 148, 220, 148); stroke(0); //Background fill(255, 255, 255, mouseY-100); quad(0, 0, 400, 0, 400, 400, 0, 400); stroke(0); // Silver Base fill(180); quad(175, 180, 225, 180, 225, 370, 175, 370); // Activation Button on lightsaber fill(100); quad(173, 240, 227, 240, 227, 285, 173, 285); quad(227, 240, 233, 240, 233, 285, 227, 285); // Black grips fill(0); quad(170, 295, 180, 295, 180, 365, 170, 365); quad(192, 295, 208, 295, 208, 365, 192, 365); quad(220, 295, 230, 295, 230, 365, 220, 365); // Blade Emitter (Where blade comes out) fill(0); quad(182, 170, 200, 170, 200, 180, 182, 180); fill(180); quad(177, 164, 203, 164, 203, 170, 175, 170); quad(177, 154, 203, 154, 203, 164, 177, 164); quad(175, 148, 215, 148, 203, 154, 177, 154); //Lightsaber top guard piece fill(180); quad(200, 180, 225, 180, 225, 130, 200, 151); //curve for guard quad(200, 152, 193, 170, 180, 180, 200, 180); //lines used to block certain stroke lines stroke(180); line(200, 180, 225, 180); line(181, 180, 200, 180); line(200, 180, 200, 155); stroke(0); // Lighstaber Blade length adjust (Red Button) fill(180); ellipseMode(CENTER); ellipse(225, 185, 10, 16); ellipse(229, 185, 10, 16); fill(180, 0, 0); ellipse(229, 185, 6, 10); // Ring tuning flange (Silver part above red button) fill(180); ellipse(233, 155, 22, 18); ellipse(230, 155, 22, 18); quad(218, 144, 235, 150, 235, 160, 218, 165); // More Lines used to grey out stroke lines stroke(180); strokeWeight(2); fill(180); line(224, 147, 235, 150); line(235, 150, 235, 160); line(235, 160, 225, 162); strokeWeight(1); stroke(0); } // deflected blaster shot void mousePressed(){ noStroke(); frameRate(3); fill(255, 0, 0); quad(225, 61, 335, 45, 335, 90, 225, 106); fill(255, 0, 0); quad(225, 61, 335, 125, 335, 170, 225, 106); fill(253, 173, 127); quad(225, 76, 335, 140, 335, 155, 225, 91); fill(253, 173, 127); quad(225, 76, 335, 60, 335, 75, 225, 91); stroke(0); }