import de.looksgood.ani.*;
import de.looksgood.ani.easing.*;
Circulo circulo;
ArrayList<Circulo> circulos = new ArrayList<Circulo>();
PShape boton;
PShape cuadrado;
PShape menu;
boolean botonOpen = false;
void setup() {
size(720, 480);
boton=loadShape("MENU.svg");
cuadrado = boton.getChild("cuadrado");
menu = boton.getChild("menu");
shapeMode(CENTER);
Ani.init(this);
circulo= new Circulo(2.0);
textAlign(CENTER, CENTER);
for (int i=0; i<10; i++) {
Circulo c = new Circulo(i*80+60, height/2);
circulos.add(c);
}
}
void draw() {
background(0);
for (int i=circulos.size ()-1; i>=0; i--)
{
circulos.get(i).display();
}
if (botonOpen) {
cuadrado.disableStyle();
menu.disableStyle();
fill(0);
stroke(90, 255, 204);
} else {
cuadrado.enableStyle();
menu.enableStyle();
}
shape(cuadrado, 300, 150);
shape(menu, 300, 150);
}
void mouseClicked() {
for (int i=0; i<circulos.size (); i++) {
circulos.get(i).actualizar();
}
botonOpen=!botonOpen;
}
----------------------------------------------------------------------------------------------------------
<Circulo>
class Circulo {
float x, y;
float destx, desty;
float origenx, origeny;
float size;
float tiempo;
boolean menuabierto;
Circulo() {
x = width/2;
y = height/4;
size = 50;
tiempo = 2.0;
}
Circulo(float destx_, float desty_) {
menuabierto= false;
x = width/2;
y = height/4;
origenx = x;
origeny = y;
destx = destx_;
desty = desty_;
size = 50;
tiempo = 2.0;
}
Circulo(float tiempo_) {
x = width/2;
y = height/2;
size = 50;
tiempo = tiempo_;
}
void actualizar() {
if (menuabierto == false) {
Ani.to(this, tiempo, "x", destx, Ani.ELASTIC_OUT);
Ani.to(this, tiempo, "y", desty, Ani.ELASTIC_OUT);
menuabierto = true;
} else {
Ani.to(this, tiempo, "x", destx, Ani.ELASTIC_OUT);
Ani.to(this, tiempo, "y", desty, Ani.ELASTIC_OUT);
menuabierto = false;
}
}
void display (){
fill(145,200,145);
ellipse(x, y, size, size);
textSize(0.25*size);
fill(255, 255, 255);
}
}