Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float bx;
- float by;
- float ax;
- float ay;
- boolean overA = false;
- boolean overB = false;
- PFont f;
- void setup() {
- size(640, 360);
- ax = 80;
- ay = 80;
- bx = 160;
- by = 80;
- f = createFont("Arial",20,true);
- }
- void draw() {
- background(0);
- textFont(f);
- char a = 'X';
- char b = 'D';
- float cwA = textWidth(a);
- float cwB = textWidth(b);
- // Text A
- if (mouseX > ax-cwA/2.0 && mouseX < ax+cwA/2.0 &&
- mouseY > ay-2*cwA && mouseY < ay) {
- overA = true;
- fill(200);
- } else {
- fill(255);
- overA = false;
- }
- text(a, ax-cwA/2.0, ay-cwA/2.0);
- // Text B
- if (mouseX > bx-cwB/2.0 && mouseX < bx+cwB/2.0 &&
- mouseY > by-2*cwB && mouseY < by) {
- overB = true;
- fill(200);
- } else {
- fill(255);
- overB = false;
- }
- text(b, bx-cwA/2.0, by-cwB/2.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement