// use begin / endshape // method to return size float arrowWidth(float h) { return (3*h)/2; } static int leftArrow = 1; static int rightArrow = 2; class Arrow { int direction; float x; float y; float h; float w; /*static float getWidth(float h) { return (3*h)/2; }*/ public Arrow(int direction, float x, float y, float h) { // add color this.direction = direction; this.x = x; this.y = y; this.h = h; this.w = arrowWidth(this.h); } void draw() { float h3 = h/3; float h2 = h/2; float midx = x+h; beginShape(); if (direction == rightArrow) { vertex(x, y+h3); vertex(x, y+2*h3); vertex(midx, y+2*h3); vertex(midx, y+h); vertex(midx+h2, y+h2); vertex(midx, y); vertex(midx, y+h3); } else if (direction == leftArrow) { vertex(midx+h2, y+h3); vertex(midx+h2, y+2*h3); vertex(x+h2, y+2*h3); vertex(x+h2, y+h); vertex(x, y+h2); vertex(x+h2, y); vertex(x+h2, y+h3); } endShape(CLOSE); } boolean contains(float x, float y) { return (x>=this.x && x<=this.x+this.w && y>=this.y && y <= this.y+this.h); } }