I'm completely new to Java Processing and I am trying to figure out a way to deign a fan which will rotate and increase the speed when press the plus(+) button and decrease when press the negative(-) button. As well as a way to display the speed which the fan is rotating.
final int coverSize=250;
final int centralDiskSize=30;
final int rectSize=50;
final int bladeSize=30;
float xPos=0, yPos=0;
float angle=250;
float bladePosX=0, bladePosY=0;
boolean button = false;
void setup(){
size(500,500);
bladePosX=width/2+coverSize;
bladePosY=height/2;
}
void draw(){
//rotateFan();
drawFan();
btton();
}
void drawFan(){
background(200);
strokeWeight(2);
noFill();
ellipse(xPos+250,yPos+250,coverSize,coverSize);
ellipse(xPos+250,yPos+250,coverSize-40,coverSize-40);
ellipse(xPos+250,yPos+250,coverSize-90,coverSize-90);
ellipse(xPos+250,yPos+250,coverSize-130,coverSize-130);
ellipse(xPos+250,yPos+250,coverSize-180,coverSize-180);
fill(0);
ellipse(xPos+250,yPos+250,centralDiskSize,centralDiskSize);
noFill();
rect(xPos+175,yPos+375,rectSize,rectSize);
rect(xPos+225,yPos+375,rectSize,rectSize);
rect(xPos+275,yPos+375,rectSize,rectSize);
}
void rotateFan(){
background(200);
ellipse(bladePosX,bladePosY,bladeSize,bladeSize);
bladePosX=width/2+coverSize*cos(angle);
bladePosY=height/2+coverSize*sin(angle);
angle=angle+(PI/90);
ellipse(bladePosX,bladePosY,bladeSize,bladeSize);
//ellipse(xPos+250,yPos+250,centralDiskSize,centralDiskSize);
//buttons();
}
void btton(){
if(button){
background(255);
stroke(0);
if (button){
void mousePressed (){
if (mouseX > xPos && mouseX < xPos+rectSize && mouseY > yPos && mouseY < yPos+rectSize){
button = !button;
}
}