Is there a library like G4P for Android

RazRaz
edited March 2016 in Android Mode

Is there library like G4P to android mode? If there is, What's its name?

Tagged:

Answers

  • You can use p5 with android. It is however pretty heavy. I wouldconsider making my own buttons etc. Here's an example of a simple button: // Usage: // Button b_1; // // void setup() { // b_1 = new Button(xPos, yPos, _width, _height, "label", 2); // } // // void draw(){ // if (b_mode.clicked){ // // do stf // b_1.display(); // } //////////////////////////////////////////////////////

    class Button { /* --- GLOBAL VARIABLES --- */

    float x, y, w, h; String label; boolean MOVER = false; boolean BDOWN = false; boolean clicked = false; int textSize = 0;

    /* --- CONSTRUCTOR --- */

    Button(float _x, float _y, float _w, float _h, String _label, int _textSize) { x = _x; y = _y; w = _w; h = _h; label = _label; textSize = _textSize; }

    /* --- METHODS --- */

    void display() { // Needs to be first if(BDOWN && MOVER && !mousePressed) { clicked = true; } else { clicked = false; }

    // Check if mouse is MOVER || && BDOWN.
    if(mouseX > x && mouseY > y && mouseX < x + w && mouseY < y + h)
    {
      MOVER = true;
      if(mousePressed)
      {
        BDOWN = true;
      }
      else
      {
        BDOWN = false;
      }
    }
    else
    {
      MOVER = false;
    }
    
    smooth();
    
    // Button (rect) color
    if(!MOVER)
    {
      fill(#113C58);
    }
    else
    {
      if(!BDOWN)
      {
        fill(#5394BF);
      }
      else
      {
        fill(0);
      }
    }
    
    stroke(255);
    rect(x, y, w, h);
    
    fill(255);
    textSize(textSize);
    textAlign(CENTER);
    text(label, x + w / 2, y + h / 2 + (textAscent() / 2));
    

    } }

  • please edit message, highlight code, hit ctrl-o

  • I have modified the discussion title to make it more relevant to the topic.

Sign In or Register to comment.