G2A Many GEOs
SHARE
TWEET

Hover,Keystrokes,Processing

a guest Apr 8th, 2020 127 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. boolean colorA = false;
  3. boolean colorB = false;
  4. PFont f;
  5.  
  6.   char a = 'R';
  7.   float ax = 80;
  8.   float ay = 80;
  9.  
  10.   char b = 'P';
  11.   float bx = 180;
  12.   float by = 80;
  13.  
  14. void setup() {
  15.   size(640, 360);
  16.   f = createFont("Arial",20,true);
  17. }
  18.  
  19. void draw() {
  20.   background(0);
  21.   textFont(f);
  22.   float cwA = textWidth(a);
  23.   float cwB = textWidth(b);
  24.  
  25.   // Text A
  26.   if (colorA == true) {
  27.     fill(204, 102, 0);
  28.     if (mouseX > ax-cwA/2.0 && mouseX < ax+cwA/2.0 &&
  29.         mouseY > ay-2*cwA && mouseY < ay) {
  30.       fill(204, 102, 0);
  31.       colorA = false;
  32.     }
  33.   } else {
  34.     if (mouseX > ax-cwA/2.0 && mouseX < ax+cwA/2.0 &&
  35.         mouseY > ay-2*cwA && mouseY < ay) {
  36.       fill(204, 102, 0);
  37.     } else {
  38.       fill(255);
  39.     }
  40.   }
  41.   text(a, ax-cwA/2.0, ay-cwA/2.0);
  42.  
  43.   // Text B
  44.   if (colorB == true) {
  45.     fill(204, 102, 0);
  46.   } else {
  47.     fill(255);
  48.   }
  49.   text(b, bx-cwB/2.0, by-cwB/2.0);
  50. }
  51.  
  52. void keyPressed() {
  53.   if (key >= 'P' && key <= 'p') {
  54.     if (colorB == true) {
  55.       colorB = false;
  56.     } else {
  57.       colorB = true;
  58.     }
  59.   }
  60.   if (key == CODED) {
  61.     if (keyCode == LEFT || keyCode == RIGHT) {
  62.     if (colorB == true) {
  63.       colorA = true;
  64.       colorB = false;
  65.     } else {
  66.       colorA = false;
  67.       colorB = true;
  68.     }
  69.     }
  70.   }
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top