// Path: core/src/main/java/com/threerings/jiggl/util/Scalar.java
// public class Scalar
// {
//     /** The current value of this scalar. */
//     public float value;
// 
//     /**
//      * Creates a scalar with the specified initial value.
//      */
//     public Scalar (float init)
//     {
//         this.value = init;
//     }
// }
// 
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
//     /** The x-component of our (container relative) translation. */
//     public final Scalar x = new Scalar(0);
// 
//     /** The y-component of our (container relative) translation. */
//     public final Scalar y = new Scalar(0);
// 
//     /** The x-component of our scale. */
//     public final Scalar scaleX = new Scalar(1);
// 
//     /** The y-component of our scale. */
//     public final Scalar scaleY = new Scalar(1);
// 
//     /** The rotation of this visible, in radians. */
//     public final Scalar rotation = new Scalar(0);
// 
//     /**
//      * Returns the width of this visible, including local scaling transformations (but not
//      * rotation). Transformations applied by a parent of this visible are also not included.
//      */
//     public abstract float getWidth ();
// 
//     /**
//      * Returns the height of this visible, including local scaling transformations (but not
//      * rotation). Transformations applied by a parent of this visible are also not included.
//      */
//     public abstract float getHeight ();
// 
//     /**
//      * Returns true if this viz is added to a view, false otherwise.
//      */
//     public abstract boolean isAdded ();
// 
//     /**
//      * Called when this viz is added to a view. The viz should prepare any buffers or shader
//      * programs it will need to render itself. Any exception thrown by this method will result in
//      * the viz not being added to the view, so the viz should ensure that partially created
//      * resources are cleaned up if it throws such an exception.
//      */
//     protected abstract void onAdd (View view);
// 
//     /**
//      * Called when this viz is removed from a view. The viz should destroy any buffers or shader
//      * programs it created in {@link #onAdd}.
//      */
//     protected abstract void onRemove ();
// 
//     /**
//      * Instructs this viz to issue the rendering calls needed to visualize itself.
//      */
//     protected abstract void render ();
// }


import com.threerings.jiggl.util.Scalar;
import com.threerings.jiggl.view.Viz;
//
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE

package com.threerings.jiggl.tween;


/**
 * Manages the animation of a particular property of a visible.
 */
public abstract class Tween
{
    /** A tween that animates a single scalar value. */
    public static class One extends Interped
    {
        public One (Interpolator interp, Scalar value) {
            super(interp);
            _value = value;
        }

        /** Configures the starting value. Default: the value of the scalar at the time that the
         * tween begins. */
        public One from (float value) {
            _from = value;
            return this;
        }

        /** Configures the ending value. Default: 0. */
        public One to (float value) {
            _to = value;
            return this;
        }

        @Override
        protected void init (float time) {
            super.init(time);
            if (_from == Float.MIN_VALUE) _from = _value.value;
        }

        @Override
        protected boolean apply (float time) {
            float dt = time-_start;
            if (dt < _duration) {
                _value.value = _interp.apply(_from, _to-_from, dt, _duration);
                return false;
            } else {
                _value.value = _to;
                return true;
            }
        }

        protected final Scalar _value;
        protected float _from = Float.MIN_VALUE;
        protected float _to;
    }

    /** A tween that animates a pair of scalar values (usually a position). */
    public static class Two extends Interped
    {
// Path: core/src/main/java/com/threerings/jiggl/util/Scalar.java
// public class Scalar
// {
//     /** The current value of this scalar. */
//     public float value;
// 
//     /**
//      * Creates a scalar with the specified initial value.
//      */
//     public Scalar (float init)
//     {
//         this.value = init;
//     }
// }
// 
// Path: core/src/main/java/com/threerings/jiggl/view/Viz.java
// public abstract class Viz
// {
//     /** The x-component of our (container relative) translation. */
//     public final Scalar x = new Scalar(0);
// 
//     /** The y-component of our (container relative) translation. */
//     public final Scalar y = new Scalar(0);
// 
//     /** The x-component of our scale. */
//     public final Scalar scaleX = new Scalar(1);
// 
//     /** The y-component of our scale. */
//     public final Scalar scaleY = new Scalar(1);
// 
//     /** The rotation of this visible, in radians. */
//     public final Scalar rotation = new Scalar(0);
// 
//     /**
//      * Returns the width of this visible, including local scaling transformations (but not
//      * rotation). Transformations applied by a parent of this visible are also not included.
//      */
//     public abstract float getWidth ();
// 
//     /**
//      * Returns the height of this visible, including local scaling transformations (but not
//      * rotation). Transformations applied by a parent of this visible are also not included.
//      */
//     public abstract float getHeight ();
// 
//     /**
//      * Returns true if this viz is added to a view, false otherwise.
//      */
//     public abstract boolean isAdded ();
// 
//     /**
//      * Called when this viz is added to a view. The viz should prepare any buffers or shader
//      * programs it will need to render itself. Any exception thrown by this method will result in
//      * the viz not being added to the view, so the viz should ensure that partially created
//      * resources are cleaned up if it throws such an exception.
//      */
//     protected abstract void onAdd (View view);
// 
//     /**
//      * Called when this viz is removed from a view. The viz should destroy any buffers or shader
//      * programs it created in {@link #onAdd}.
//      */
//     protected abstract void onRemove ();
// 
//     /**
//      * Instructs this viz to issue the rendering calls needed to visualize itself.
//      */
//     protected abstract void render ();
// }


// Path: core/src/main/java/com/threerings/jiggl/tween/Tween.java
import com.threerings.jiggl.util.Scalar;
import com.threerings.jiggl.view.Viz;

//
// Jiggl Core - 2D game development library
// http://github.com/threerings/jiggl/blob/master/LICENSE

package com.threerings.jiggl.tween;


/**
 * Manages the animation of a particular property of a visible.
 */
public abstract class Tween
{
    /** A tween that animates a single scalar value. */
    public static class One extends Interped
    {
        public One (Interpolator interp, Scalar value) {
            super(interp);
            _value = value;
        }

        /** Configures the starting value. Default: the value of the scalar at the time that the
         * tween begins. */
        public One from (float value) {
            _from = value;
            return this;
        }

        /** Configures the ending value. Default: 0. */
        public One to (float value) {
            _to = value;
            return this;
        }

        @Override
        protected void init (float time) {
            super.init(time);
            if (_from == Float.MIN_VALUE) _from = _value.value;
        }

        @Override
        protected boolean apply (float time) {
            float dt = time-_start;
            if (dt < _duration) {
                _value.value = _interp.apply(_from, _to-_from, dt, _duration);
                return false;
            } else {
                _value.value = _to;
                return true;
            }
        }

        protected final Scalar _value;
        protected float _from = Float.MIN_VALUE;
        protected float _to;
    }

    /** A tween that animates a pair of scalar values (usually a position). */
    public static class Two extends Interped
    {
        public Two (Interpolator interp, Scalar x, Scalar y) {