b-g / Ani

A lightweight animation library for the programming environment Processing
79 stars 13 forks source link

get all Easings #7

Closed clankill3r closed 10 years ago

clankill3r commented 10 years ago

I finally managed to create a ArrayList with Easing objects. But it would be nice if there was something like:

Ani.getAllEasings();

So it can be more convenient to fill an ArrayList.

import de.looksgood.ani.*;
import de.looksgood.ani.easing.Easing;

ArrayList<Easing> easings = new ArrayList<Easing>();

int index = 0;

float x = 256;
float y = 256;
int diameter = 50;

void setup() {
  size(512,512);
  smooth();
  noStroke();

  // you have to call always Ani.init() first!
  Ani.init(this);

  easings.add(Ani.BOUNCE_OUT);
  easings.add(Ani.LINEAR);
 easings.add(Ani.QUAD_IN);
 easings.add(Ani.QUAD_OUT);
 easings.add(Ani.QUAD_IN_OUT);
 easings.add(Ani.CUBIC_IN);
 easings.add(Ani.CUBIC_IN_OUT);
 easings.add(Ani.CUBIC_OUT);
 easings.add(Ani.QUART_IN);
 easings.add(Ani.QUART_OUT);
 easings.add(Ani.QUART_IN_OUT);
 easings.add(Ani.QUINT_IN);
 easings.add(Ani.QUINT_OUT);
 easings.add(Ani.QUINT_IN_OUT);
 easings.add(Ani.SINE_IN);
 easings.add(Ani.SINE_OUT);
 easings.add(Ani.SINE_IN_OUT);
 easings.add(Ani.CIRC_IN);
 easings.add(Ani.CIRC_OUT);
 easings.add(Ani.CIRC_IN_OUT);
 easings.add(Ani.EXPO_IN);
 easings.add(Ani.EXPO_OUT);
 easings.add(Ani.EXPO_IN_OUT);
 easings.add(Ani.BACK_IN);
 easings.add(Ani.BACK_OUT);
 easings.add(Ani.BACK_IN_OUT);
 easings.add(Ani.BOUNCE_IN);
 easings.add(Ani.BOUNCE_OUT);
 easings.add(Ani.BOUNCE_IN_OUT);
 easings.add(Ani.ELASTIC_IN);
 easings.add(Ani.ELASTIC_OUT);
 easings.add(Ani.ELASTIC_IN_OUT);

}

void draw() {
  background(255);
  fill(0);
  ellipse(x,y,diameter,diameter);
}

void mouseReleased() {
  println("index: "+index);
  Ani.to(this, 1.0, "x", mouseX, easings.get(index));
  Ani.to(this, 1.0, "y", mouseY, easings.get(index));
}

void keyPressed() {
  if (key == '[' || key == '{') {
    index--;
  } 
   else if (key == ']' || key == '}') {
     index++;
  }
  index = constrain(index, 0, easings.size()-1);
}
b-g commented 10 years ago

many thanks for the example!

but i don't get why this would be crazy useful, seems be more or less the same like https://github.com/b-g/Ani/blob/master/examples/Ani_Easing_Viewer/Ani_Easing_Viewer.pde, or? :)

do you have an other example/usecase in mind? i just want to fully understand why you want to have the feature ... please let me know.

all the best, benedikt

clankill3r commented 10 years ago

Damn, i must have skipped that example. Maybe it's good to drop the current Ani_Easing_Styles.pde example and rename Ani_Easing_Viewer.pde to Styles. Just to reduce the amount of examples.

b-g commented 10 years ago

Ok + :)