//////////////Ariana Tomcsak//////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////ASSIGNMENT 2 - INTERACTIVE Toy////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
///////////LIGHTS - OFF///////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
////////////////LET'S PLAY!///////////////////////////////////////////////////////
////Use the fly (cursor) to hover above the light switch and turn the lights off//
////Click the mouse to hear the fly 'buzz'////////////////////////////////////////
///////VARIABLES//////////
float leftbulbX;
float leftbulbY;
float rightbulbX;
float rightbulbY;
float backbulbX;
float backbulbY;
int bulbHeight;
int bulbWidth;
///////SETUP//////////////
void setup() {
size(400, 400);
ellipseMode(CENTER);
rectMode(CENTER);
leftbulbX = 65;
leftbulbY = 240;
rightbulbX = 185;
rightbulbY = 250;
backbulbX = 0;
backbulbY = 140;
bulbHeight = 20;
bulbWidth = 400;
}
///////DRAW//////////////
void draw() {
background (255);
noStroke();
////Draw background////
drawBackgroundGradient();
//*loop back bulb across x-axis////
backbulbX = - 30;
while (backbulbX < bulbWidth) {
backbulbX = backbulbX + 66 ;
drawBackBulb();
}
////Draw foreground////
drawOnOffSwitch();
drawLeftBulb();
drawRightBulb();
drawFly();
if (mouseX > 325 && mouseX < 335 && mouseY < 258 && mouseY > 222) {
background (0);
}
}
////Mouse Press Fun////
void mousePressed() {
//*make the bug talk//*
println("BZZZZZT");
}
///////FUNCTION DEFINITIONS///////
void drawBackgroundGradient() {
//////Draw background gradient////
//*background rect 1//*
fill(168, 103, 90, 200);
rect(bulbWidth/2, bulbHeight, bulbWidth, bulbHeight*2);
//*background rect 2//*
fill(189, 115, 101, 200);
rect(bulbWidth/2, bulbHeight*3, bulbWidth, bulbHeight*2);
//*background rect 3//*
fill(229, 140, 123, 200);
rect(bulbWidth/2, bulbHeight*5, bulbWidth, bulbHeight*2);
//*background rect 4//*
fill(255, 156, 137, 200);
rect(bulbWidth/2, bulbHeight*7, bulbWidth, bulbHeight*2);
//*background rect 5//*
fill(229, 140, 123, 200);
rect(bulbWidth/2, bulbHeight*9, bulbWidth, bulbHeight*2);
//*background rect 6//*
fill(189, 115, 101, 200);
rect(bulbWidth/2, bulbHeight*11, bulbWidth, bulbHeight*2);
//*background rect 7//*
fill(168, 103, 90, 200);
rect(bulbWidth/2, bulbHeight*13, bulbWidth, bulbHeight*2);
//*background rect 8//*
fill(145, 89, 78, 200);
rect(bulbWidth/2, bulbHeight*15, bulbWidth, bulbHeight*2);
//*background rect 9//*
fill(127, 78, 68, 200);
rect(bulbWidth/2, bulbHeight*17, bulbWidth, bulbHeight*2);
//*background rect 10//*
fill(105, 64, 56, 200);
rect(bulbWidth/2, bulbHeight*19, bulbWidth, bulbHeight*2);
//*background rect 11//*
fill(89, 55, 48, 200);
rect(bulbWidth/2, bulbHeight*21, bulbWidth, bulbHeight*2);
}
void drawBackBulb() {
//Draw & color light bulb & light rays in the background////
//**white ellipse behind bulb and rays for transparency problem//*
fill(255, 140);
ellipse(backbulbX, backbulbY, 15, 15);
//*ray1 in background & color//*
fill(186, 174, 121, random(50, 100));
ellipse(backbulbX, backbulbY, 15, 15);
//*light source in background & color//*
fill(194, 181, 126, random(150, 200));
ellipse(backbulbX, backbulbY, 10, 10);
//*ray3 in background & color//*
fill(255, 251, 207, random(50, 100));
ellipse(backbulbX, backbulbY, 50, 50);
//*ray2 in background & color//*
fill(186, 174, 121, random(0, 50));
ellipse(backbulbX, backbulbY, 30, 30);
}
void drawOnOffSwitch() {
////Draw light on/off chord & color////
//*chord//*
strokeWeight(2);
stroke(142, 150, 100);
fill(172, 181, 120);
rect(330, 100, 5, 250);
//*pull handle//*
strokeWeight(2);
stroke(143, 135, 114);
fill(168, 160, 135);
rect(330, 240, 10, 35);
}
void drawLeftBulb2() {
////Draw & color left bulb, rays, chord & attachments////
//*chord & color//*
strokeWeight(2);
stroke(184, 145, 96);
fill(247, 195, 129);
rect(leftbulbX, 90, 5, 200);
///Attachments & color///
//*big bottom & color//*
stroke(153, 153, 149);
fill(186, 185, 180);
ellipse(leftbulbX, 200, 45, 15);
//*medium bottom & color//*
stroke(133, 133, 129);
fill(166, 165, 161);
ellipse(leftbulbX, 190, 35, 15);
//*small bottom & collor//*
stroke(122, 122, 119);
fill(150, 150, 146);
ellipse(leftbulbX, 180, 25, 12);
///Left bulb rays & color///
//*bulb ray 3 & color//*
noStroke();
fill(255, 251, 88, random(20, 10));
ellipse(leftbulbX, leftbulbY, 180, 180);
//*bulb ray 2 & color//*
noStroke();
fill(255, 251, 88, random(20, 40));
ellipse(leftbulbX, leftbulbY, 140, 140);
//*bulb ray 1 & color//*
noStroke();
fill(255, 251, 88, random(30, 45));
ellipse(leftbulbX, leftbulbY, 100, 100);
}
void drawLeftBulb() {
////Draw & color left bulb, rays, chord & attachments////
//*chord & color//*
strokeWeight(2);
stroke(184, 145, 96);
fill(247, 195, 129);
rect(leftbulbX, 90, 5, 200);
///Left bulb & color///
//*white ellipse behind bulb for transparency problem//*
noStroke();
fill(255, 200);
ellipse(leftbulbX, leftbulbY, 80, 80);
drawBulbInsideSmallLeft();
//*bulb & color//*
noStroke();
fill(255, 251, 88, 100);
ellipse(leftbulbX, leftbulbY, 80, 80);
///Attachments & color///
//*big bottom & color//*
stroke(153, 153, 149);
fill(186, 185, 180);
ellipse(leftbulbX, 200, 45, 15);
//*medium bottom & color//*
stroke(133, 133, 129);
fill(166, 165, 161);
ellipse(leftbulbX, 190, 35, 15);
//*small bottom & collor//*
stroke(122, 122, 119);
fill(150, 150, 146);
ellipse(leftbulbX, 180, 25, 12);
///Left bulb rays & color///
//*bulb ray 3 & color//*
noStroke();
fill(255, 251, 88, random(20, 10));
ellipse(leftbulbX, leftbulbY, 180, 180);
//*bulb ray 2 & color//*
noStroke();
fill(255, 251, 88, random(20, 40));
ellipse(leftbulbX, leftbulbY, 140, 140);
//*bulb ray 1 & color//*
noStroke();
fill(255, 251, 88, random(30, 45));
ellipse(leftbulbX, leftbulbY, 100, 100);
}
void drawRightBulb() {
////Draw & color right bulb, rays, chord & attachments////
//*chord & color//*
stroke(112, 133, 122);
fill(155, 184, 169);
rect(rightbulbX, 90, 5, 185);
///Right bulb & color///
//*white rect behind bulb for transparency problem//*
noStroke();
fill(255, 200);
rect(rightbulbX, rightbulbY, 40, 140, 20);
drawBulbInsideLongRight();
//*bulb & color//*
noStroke();
fill(255, 251, 88, 100);
rect(rightbulbX, rightbulbY, 40, 140, 20);
///Attachments & color///
//*big bottom * color//*
stroke(153, 153, 149);
fill(186, 185, 180);
ellipse(rightbulbX, 180, 45, 15);
//*medium bottom & color//*
stroke(133, 133, 129);
fill(166, 165, 161);
ellipse(rightbulbX, 170, 35, 15);
//*small bottom & color//*
stroke(122, 122, 119);
fill(150, 150, 146);
ellipse(rightbulbX, 160, 25, 12);
///Right bulb rays & color///
//*bulb ray 3 & color//*
noStroke();
fill(255, 251, 88, random(20, 10));
ellipse(rightbulbX, rightbulbY, 140, 240);
//*bulb ray 2 & color//*
noStroke();
fill(255, 251, 88, random(20, 40));
ellipse(rightbulbX, rightbulbY, 100, 200);
//*bulb ray 1 & color//*
noStroke();
fill(255, 251, 88, random(30, 45));
ellipse(rightbulbX, rightbulbY, 60, 160);
}
void drawFly() {
////////////////////////////////////////////////////////////////////////////
/////////Fly used from myself from previous assignment (assignment 1 )//////////
////////////////////////////////////////////////////////////////////////////
////Draw fly/cursor////
//*set noStroke//*
noStroke();
//*fly wing back//*
fill(255, random(80, 160));
ellipse(mouseX, mouseY - 5, 7, 10);
//*fly body//*
fill(0);
ellipse(mouseX, mouseY, 10, 10);
//*fly wing front//*
fill(255, random(100, 200));
ellipse(mouseX + 3, mouseY - 5, 7, 10);
}
////Assigned separately to ease bulb code////
void drawBulbInsideSmallLeft() {
//*inside small bulb shine & color//*
noFill();
strokeWeight(10);
stroke(255, 207, 150, random(30, 230));
line(62.5, 197, 50, 240);
ellipse(49, 242, 6, 6);
line(52, 243, 63, 250);
ellipse(67, 250, 8, 8);
line(72, 250, 80, 245);
ellipse(83, 243, 5.5, 5.5);
line(83, 240, 67.5, 197);
//*inside small bulb & color//*
strokeWeight(2);
stroke(138, 119, 82);
line(62.5, 197, 50, 240);
ellipse(49, 242, 6, 6);
line(52, 243, 63, 250);
ellipse(67, 250, 8, 8);
line(72, 250, 80, 245);
ellipse(83, 243, 5.5, 5.5);
line(83, 240, 67.5, 197);
}
void drawBulbInsideLongRight() {
//*inside long bulb shine & color//*
noFill();
strokeWeight(10);
stroke(255, 207, 150, random(0, 230));
line(182.5, 180, 177, 290);
ellipse(176, 292, 7, 7);
line(179, 292, 183, 295);
ellipse(186, 298, 5.5, 5.5);
line(188, 296, 193, 290);
ellipse(194, 288, 4, 4);
line(194, 285, 187.5, 180);
//*inside long bulb & color//*
strokeWeight(2);
stroke(138, 119, 82);
line(182.5, 180, 177, 289);
ellipse(176, 292, 7, 7);
line(179, 292, 183, 295);
ellipse(186, 298, 5.5, 5.5);
line(188, 296, 193, 290);
ellipse(194, 288, 4, 4);
line(194, 285, 187.5, 180);
}