class Draggable { int x,y,z,size,c1,c2; String mode,label; boolean locked = false; Draggable (int x, int y, int size, color c1, color c2, String mode, String label) { this.x = x; this.y = y; this.size = size; this.c1 = c1; this.c2 = c2; this.mode = mode; this.label = label; } //methods void draw(){ stroke(c2); noFill(); if (mode == "rect"){ rect(x,y,size,size); } if (mode == "ellipse"){ ellipse(x,y,size,size); ellipse(x*3,y*3,size*3,size*3); } if (locked || over()){ fill(c1); } else{ fill(c2); } text(label,x,y); } void update(){ if (over() && mousePressed){ locked = true; } if (locked){ x = mouseX; y = mouseY; } if (!mousePressed){ locked = false; } } boolean over(){ if (mouseX <= x+size && mouseX >= x-size && mouseY <= y+size && mouseY >= y-size){ return true; } else{ return false; } } }