-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathButton.js
More file actions
30 lines (27 loc) · 653 Bytes
/
Copy pathButton.js
File metadata and controls
30 lines (27 loc) · 653 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var mouseIsReleased=true;
function mouseReleased(){
mouseIsReleased=true;
}
function Button(x,y,w,h,t,ts,xOffset=5,onColor=[165,230,250]){
this.clicked =false;
this.text=t;
this.update = function(){
if(this.clicked){
fill(onColor[0],onColor[1],onColor[2],120);
}else{
fill(30,30,30,100);
}
noStroke();
rect(x,y,w,h,10);
fill(0);
textSize(ts);
stroke(0);
text(this.text,x+xOffset,y+h-10);
if(mouseIsPressed && mouseX>x && mouseX<(x+w) && mouseY>y && mouseY<y+h && mouseIsReleased){
this.clicked = true;
mouseIsReleased = false;
}else{
this.clicked = false;
}
}
}