-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrowLabel.pde
More file actions
47 lines (40 loc) · 1.33 KB
/
ArrowLabel.pde
File metadata and controls
47 lines (40 loc) · 1.33 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class ArrowLabel {
String label;
int x, y, r, pointerWidth, lwidth, lheight;
color textcolor, textcolorhover;
ArrowLabel(String label, color textcolor, color textcolorhover, int pointToX, int pointToY, int r, int pointerWidth) {
this.label = label;
this.textcolor = textcolor;
this.textcolorhover = textcolorhover;
this.pointerWidth = pointerWidth;
this.lwidth = ceil(textWidth(this.label));
this.lheight = ceil(textAscent()+textDescent());
this.x = pointToX - (pointerWidth + r + lwidth);
this.y = pointToY - lheight/2;
}
boolean contains(int x, int y) {
if(x > this.x && x < (this.x+this.lwidth) && y > this.y && y < (this.y+this.lheight)) {
return true;
}
return false;
}
void draw() {
lwidth = ceil(textWidth(label)) + 2;
lheight = ceil(textAscent()+textDescent()) + 2;
beginShape();
vertex(x+r,y);
vertex(x+r+lwidth,y);
vertex(x+r+lwidth+pointerWidth,y+lheight/2);
vertex(x+r+lwidth,y+lheight);
vertex(x+r,y+lheight);
bezierVertex(x,y+lheight,x,y+lheight,x,y+lheight-r);
vertex(x,y+r);
bezierVertex(x,y,x,y,x+r,y);
endShape();
pushStyle();
fill(contains(mouseX,mouseY) ? this.textcolorhover : this.textcolor);
textAlign(LEFT,TOP);
text(this.label, this.x + this.r + 2, this.y + 2);
popStyle();
}
}