Android Open Source - AniDroid Ani Util






From Project

Back to project page AniDroid.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project AniDroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.mediavrog.ani;
//www  .  java  2s.  c om
public class AniUtil {

  /**
   * @see <a href="http://processing.googlecode.com/svn/trunk/processing/build/javadoc/core/processing/core/PConstants.html">processing/core/PConstants</a>
   */
  private static final float TWO_PI = 6.28318530717958647693f;

  /**
   * Calculates the minimal difference of two angles given in radians.
   * by Hartmut Bohnacker.
   *
   * @param theAngle1 Angle to subtract from
   * @param theAngle2 Angle to subtract
   * @return Angle between -PI and PI (-180? and 180?)
   */
  public static float shortRotation(float theAngle1, float theAngle2) {
    float a1 = (theAngle1 % TWO_PI + TWO_PI) % TWO_PI;
    float a2 = (theAngle2 % TWO_PI + TWO_PI) % TWO_PI;

    if (a2 > a1) {
      float d1 = a2 - a1;
      float d2 = a1 + TWO_PI - a2;
      if (d1 <= d2) {
        return -d1;
      } else {
        return d2;
      }
    } else {
      float d1 = a1 - a2;
      float d2 = a2 + TWO_PI - a1;
      if (d1 <= d2) {
        return d1;
      } else {
        return -d2;
      }
    }
  }

  public static float constrain(float theValue, float min, float max) {
    return theValue < min ? min : (theValue > max ? max : theValue);
  }

  /**
   * @see <a href="https://github.com/esmasui/processing-fragment/blob/master/core/src/processing/core/PApplet.java">processing/core/PApplet</a>
   */
  public static final float map(float value,
                  float istart, float istop,
                  float ostart, float ostop) {
    return ostart + (ostop - ostart) * ((value - istart) / (istop - istart));
  }
}




Java Source Code List

net.mediavrog.ani.AniConstants.java
net.mediavrog.ani.AniCore.java
net.mediavrog.ani.AniSequence.java
net.mediavrog.ani.AniUtil.java
net.mediavrog.ani.Ani.java
net.mediavrog.ani.AnimationStateChangeListener.java
net.mediavrog.ani.Animation.java
net.mediavrog.ani.SimpleAnimationStateChangeListener.java
net.mediavrog.ani.easing.Back.java
net.mediavrog.ani.easing.Bounce.java
net.mediavrog.ani.easing.Circ.java
net.mediavrog.ani.easing.Cubic.java
net.mediavrog.ani.easing.CustomEasing.java
net.mediavrog.ani.easing.Easing.java
net.mediavrog.ani.easing.Elastic.java
net.mediavrog.ani.easing.Expo.java
net.mediavrog.ani.easing.Linear.java
net.mediavrog.ani.easing.Quad.java
net.mediavrog.ani.easing.Quart.java
net.mediavrog.ani.easing.Quint.java
net.mediavrog.ani.easing.Sine.java