int polarFlip = 1;
float aPos = 315;
float bPos = 315;
float cPos = 315;
float dPos = 265;
float ePos = 265;
float fPos = 265;
float gPos = 315;
void setup(){
size(400,400);
smooth();
}
void draw(){
background(0,0,0);
bodyRender();
waveRender(35,262,100);
switchRender();
holoRender();
}
float wave(float xPos){
////////////////////////////////////////////////////////
// Calculates Y Position of Given X Value in Waveform //
////////////////////////////////////////////////////////
float y = 0;
if(polarFlip == 1){
// Toggles Which Wave Advances With Time
y = ((aPos-280)/1.6)*((float)(Math.cos(((bPos-270)*0.88)*xPos+(frameCount/8))))+100+((cPos-280)/1.6)*((float)(Math.sin(10*xPos)))+100;
}
else{
y = ((aPos-280)/1.6)*((float)(Math.cos(((bPos-270)*0.88)*xPos)))+100+((cPos-280)/1.6)*((float)(Math.sin(10*xPos+(frameCount/8))))+100;
}
return y;
}
void waveRender(float xShift, float yShift, float scale){
///////////////////////////////
// Draws Screen and Waveform //
///////////////////////////////
noStroke();
fill((dPos-252),(ePos-252),(fPos-252));
beginShape();
vertex(xShift,yShift+(scale/20));
vertex(xShift+(scale/20), yShift);
vertex(xShift+scale-(scale/20), yShift);
vertex(xShift+scale, yShift+(scale/20));
vertex(xShift+scale, yShift+scale-(scale/20));
vertex(xShift+scale-(scale/20), yShift+scale);
vertex(xShift+(scale/20), yShift+scale);
vertex(xShift, yShift+scale-(scale/20));
endShape(CLOSE);
fill((dPos-252)*3,(ePos-252)*3,(fPos-252)*3);
ellipseMode(CORNER);
ellipse(xShift,yShift,scale,scale);
for(int i=0; i<400; i=i+10){
strokeWeight(2);
stroke((dPos-252)*10,(ePos-252)*10,(fPos-252)*10);
line(i/(400/scale)+xShift,wave(i)/(400/scale)+yShift,(i+10)/(400/scale)+xShift,wave(i+10)/(400/scale)+yShift);
}
strokeWeight(2);
stroke((dPos-252)*10,(ePos-252)*10,(fPos-252)*10,150);
line(xShift+(scale/4), yShift+(scale/2), xShift+(scale-(scale/4)), yShift+(scale/2));
line(xShift+(scale/2), yShift+(scale/4), xShift+(scale/2), yShift+(scale-(scale/4)));
}
float dialShift(float xPos, float yPos, float xRange, float yRange, float pos, boolean axis){ // bounds of dial, current state, indicator axis of movement (true = y)
////////////////////////////////////////////////////////////////
// Checks if a Dial has Been Clicked, and Adjusts Accordingly //
////////////////////////////////////////////////////////////////
float shift = 0;
if(mouseX >= xPos && mouseX <= xRange && mouseY >= yPos && mouseY <= yRange){
if (axis == true){
shift = mouseY - pos;
}
else{
shift = mouseX - pos;
}
}
return shift;
}
boolean buttonToggle(float xPos, float yPos, float xRange, float yRange){
if(mouseX >= xPos && mouseX <= xRange && mouseY >= yPos && mouseY <= yRange){
return true;
}
else{
return false;
}
}
void switchRender(){
//////////////////////////////////
// Draws the Holotron Interface //
//////////////////////////////////
noStroke();
fill(32,32,32);
rectMode(CORNERS);
rect(149,279,151,351);
rect(174,279,176,351);
rect(199,279,201,351);
rect(297,275,299,350);
fill(100,100,100);
rectMode(CENTER);
rect(150,aPos,16,6);
rect(175,bPos,16,6);
rect(200,cPos,16,6);
rect(298,gPos,16,6);
ellipseMode(CENTER);
ellipse(265,280,30,30);
ellipse(265,315,30,30);
ellipse(265,350,30,30);
fill(175,175,175);
ellipse(dPos,(float)(0.077*Math.pow((dPos-265),2)+267),4,4);
ellipse(ePos,(float)(0.077*Math.pow((ePos-265),2)+302),4,4);
ellipse(fPos,(float)(0.077*Math.pow((fPos-265),2)+337),4,4);
fill(100,100,100);
ellipse(225,350,18,18);
fill(255,30,16);
ellipse(225,350,10,10);
rectMode(CORNERS);
fill(100,100,100);
rect(310,265,335,360);
fill(245,245,170);
rect(314,269,331,356);
fill(100,100,100,150);
rect(320,272,331,273);
rect(325,282,331,283);
rect(320,292,331,293);
rect(325,302,331,303);
rect(320,312,331,313);
rect(325,322,331,323);
rect(320,332,331,333);
rect(325,342,331,343);
rect(320,352,331,353);
fill(255,30,16);
rect(314,gPos-1,327,gPos+1);
}
void holoRender(){
////////////////////////
// Draws the Hologram //
////////////////////////
int opacity = (int)(225-random(abs(200-((gPos-265)*4)+20)));
float scale = bPos-250;
float moonX = (float)(1.4*scale*sin(PI*frameCount/(aPos-260)+PI*((cPos-315)/35))+200);
float moonY = (float)(0.7*scale*Math.sin(PI*frameCount/(aPos-260))+100);
float R = ePos + fPos - 504;
float G = dPos + fPos - 504;
float B = dPos + ePos - 504;
if(polarFlip == 1){
fill((dPos-252)*6,(ePos-252)*6,(fPos-252)*6,opacity/2);
}
else{
fill(R*3,G*3,B*3,opacity/2);
}
quad(50,200,(200-1.25*scale),100,200,(100-0.5*scale),200,(100+0.5*scale));
quad(350,200,200,(100+0.5*scale),200,(100-0.5*scale),(200+1.25*scale),100);
triangle(50,200,moonX-0.075*scale,moonY,moonX+0.075*scale,moonY);
triangle(350,200,moonX-0.075*scale,moonY,moonX+0.075*scale,moonY);
ellipseMode(CENTER);
if(polarFlip == 1){
fill((dPos-252)*10,(ePos-252)*10,(fPos-252)*10,opacity);
}
else{
fill(R*5,G*5,B*5,opacity);
}
arc(200,100,scale,scale,0,PI);
if(polarFlip == 1){
fill((dPos-252)*8,(ePos-252)*8,(fPos-252)*8,opacity);
}
else{
fill(R*4,G*4,B*4,opacity);
}
ellipse(200,100,2.5*scale,scale/2);
ellipse(moonX,moonY,0.15*scale,0.15*scale);
if(polarFlip == 1){
fill((dPos-252)*10,(ePos-252)*10,(fPos-252)*10,opacity);
}
else{
fill(R*5,G*5,B*5,opacity);
}
arc(200,100,scale,scale,PI,2*PI);
arc(200,100,scale,scale/10,0,PI);
}
void bodyRender(){
////////////////////////////////////
// Draws the Body of the Holotron //
////////////////////////////////////
fill(150,150,150);
triangle(50,200,200,235,200,250);
triangle(350,200,200,235,200,250);
fill(100,100,100);
ellipse(200,250,70,60);
ellipse(50,200,15,15);
ellipse(350,200,15,15);
fill(235,228,190);
beginShape();
vertex(25,365);
vertex(25,260);
vertex(35,250);
vertex(365,250);
vertex(375,260);
vertex(375,365);
vertex(365,375);
vertex(35,375);
endShape(CLOSE);
}
void mousePressed(){
//////////////////////////////////////
// Checks if any Dials were Pressed //
//////////////////////////////////////
aPos = aPos + dialShift(142,280,158,350,aPos,true);
bPos = bPos + dialShift(167,280,183,350,bPos,true);
cPos = cPos + dialShift(192,280,208,350,cPos,true);
dPos = dPos + dialShift(252,267,277,283,(int)dPos,false);
ePos = ePos + dialShift(252,302,277,318,(int)ePos,false);
fPos = fPos + dialShift(252,337,277,353,(int)fPos,false);
gPos = gPos + dialShift(290,275,306,350,gPos,true);
if(buttonToggle(220,345,230,355)){
polarFlip = -polarFlip;
}
}