//declare all variables as floats int dispayw=260, displayh=80; int togglew=80, toggleh=8; PFont f; boolean light=true, alarmOn, twelveOn, celsiusOn; void setup(){ size(300,600); noStroke(); rectMode(CORNER); smooth(); //load font f = loadFont("HelveticaNeue-25.vlw"); textFont(f); //white background background(255); //display area fill(100); rect(0,50,width,300); //snooze light button fill(30,30,140); ellipse(width/2,400,25,25); //control box background fill(220); rect(0,450,width,150); fill(100); rect(0,450,width,10); //set circles fill(30,30,140); ellipse(50, 480, 15,15); ellipse(50, 510, 15,15); //triangles up triangle (40, 555,50, 545, 60, 555); //hr triangle (70, 555,80, 545, 90, 555); //min //triangles down triangle (40, 570,50, 580, 60, 570); //hr triangle (70, 570,80, 580, 90, 570); //min drawToggle(); textFont(f, 12); text("SNOOZE / LIGHT", width/2-45, 380); text("ALARM", width/2+40, 484); text("HOUR",width/2+45, 524); text("TEMP TYPE", width/2+30, 564); text("HR", 42,567); text("MIN", 70, 567); text("ON",width/2,494); text("OFF",width/2+102,494); text("12",width/2+3,534); text("24",width/2+102,534); text("C",width/2+3,574); text("F",width/2+102,574); text("SET ALARM",63, 485); text("SET CLOCK",63, 515); } void draw(){ //noStroke(); if(light){ fill(200); drawDisplay(); } } void mousePressed(){ //light switch if(mouseX > width/2-15 && mouseX385 && mouseY<415){ fill(235,255,115); drawDisplay(); light=!light; } } void mouseReleased(){ //alarm toggle if(mouseX > width/2 && mouseX < (width/2+20) && mouseY > 485 && mouseY < 495){ alarmOn=true; fill(0,255,40); rect(width/2+25, 485, 10, toggleh); fill(30,30,140); rect(width/2+85, 485, 10, toggleh); } if(mouseX > width/2+20+togglew && mouseX < (width/2+20+togglew+30) && mouseY > 485 && mouseY < 495){ alarmOn=false; fill(0,255,40); rect(width/2+85, 485, 10, toggleh); fill(30,30,140); rect(width/2+25, 485, 10, toggleh); } //hour toggle if(mouseX > width/2 && mouseX < (width/2+20) && mouseY > 525 && mouseY < 535){ twelveOn=true; fill(0,255,40); rect(width/2+25, 525, 10, toggleh); fill(30,30,140); rect(width/2+85, 525, 10, toggleh); } if(mouseX > width/2+20+togglew && mouseX < (width/2+20+togglew+30) && mouseY > 525 && mouseY < 535){ twelveOn=false; fill(0,255,40); rect(width/2+85, 525, 10, toggleh); fill(30,30,140); rect(width/2+25, 525, 10, toggleh); } //temperature toggle if(mouseX > width/2 && mouseX < (width/2+20) && mouseY > 565 && mouseY < 575){ celsiusOn=true; fill(0,255,40); rect(width/2+25, 565, 10, toggleh); fill(30,30,140); rect(width/2+85, 565, 10, toggleh); } if(mouseX > width/2+20+togglew && mouseX < (width/2+20+togglew+30) && mouseY > 565 && mouseY < 575){ celsiusOn=false; fill(0,255,40); rect(width/2+85, 565, 10, toggleh); fill(30,30,140); rect(width/2+25, 565, 10, toggleh); } } void drawToggle(){ rect(width/2+20, 485, togglew, toggleh); //alarm rect(width/2+20, 525, togglew, toggleh); //hour rect(width/2+20, 565, togglew, toggleh); //temp type } void drawDisplay(){ rect(20,80,dispayw, displayh); rect(20,165,dispayw, displayh); rect(20,250,dispayw, displayh); }