Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8ac7756 authored by John Reck's avatar John Reck
Browse files

More native interpolators

 Gotta collect 'em all

Change-Id: I3ccc2b5c842b27b906c8a0470fbedc2bf285bc38
parent 315c3295
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -20,12 +20,17 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.AttributeSet;


import com.android.internal.view.animation.HasNativeInterpolator;
import com.android.internal.view.animation.NativeInterpolatorFactory;
import com.android.internal.view.animation.NativeInterpolatorFactoryHelper;

/**
/**
 * An interpolator where the rate of change starts out slowly and 
 * An interpolator where the rate of change starts out slowly and 
 * and then accelerates.
 * and then accelerates.
 *
 *
 */
 */
public class AccelerateInterpolator implements Interpolator {
@HasNativeInterpolator
public class AccelerateInterpolator implements Interpolator, NativeInterpolatorFactory {
    private final float mFactor;
    private final float mFactor;
    private final double mDoubleFactor;
    private final double mDoubleFactor;


@@ -64,4 +69,10 @@ public class AccelerateInterpolator implements Interpolator {
            return (float)Math.pow(input, mDoubleFactor);
            return (float)Math.pow(input, mDoubleFactor);
        }
        }
    }
    }

    /** @hide */
    @Override
    public long createNativeInterpolator() {
        return NativeInterpolatorFactoryHelper.createAccelerateInterpolator(mFactor);
    }
}
}
+12 −1
Original line number Original line Diff line number Diff line
@@ -20,10 +20,15 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.AttributeSet;


import com.android.internal.view.animation.HasNativeInterpolator;
import com.android.internal.view.animation.NativeInterpolatorFactory;
import com.android.internal.view.animation.NativeInterpolatorFactoryHelper;

/**
/**
 * An interpolator where the change starts backward then flings forward.
 * An interpolator where the change starts backward then flings forward.
 */
 */
public class AnticipateInterpolator implements Interpolator {
@HasNativeInterpolator
public class AnticipateInterpolator implements Interpolator, NativeInterpolatorFactory {
    private final float mTension;
    private final float mTension;


    public AnticipateInterpolator() {
    public AnticipateInterpolator() {
@@ -53,4 +58,10 @@ public class AnticipateInterpolator implements Interpolator {
        // a(t) = t * t * ((tension + 1) * t - tension)
        // a(t) = t * t * ((tension + 1) * t - tension)
        return t * t * ((mTension + 1) * t - mTension);
        return t * t * ((mTension + 1) * t - mTension);
    }
    }

    /** @hide */
    @Override
    public long createNativeInterpolator() {
        return NativeInterpolatorFactoryHelper.createAnticipateInterpolator(mTension);
    }
}
}
+13 −1
Original line number Original line Diff line number Diff line
@@ -19,6 +19,11 @@ package android.view.animation;
import android.content.Context;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.AttributeSet;

import com.android.internal.view.animation.HasNativeInterpolator;
import com.android.internal.view.animation.NativeInterpolatorFactory;
import com.android.internal.view.animation.NativeInterpolatorFactoryHelper;

import static com.android.internal.R.styleable.AnticipateOvershootInterpolator_extraTension;
import static com.android.internal.R.styleable.AnticipateOvershootInterpolator_extraTension;
import static com.android.internal.R.styleable.AnticipateOvershootInterpolator_tension;
import static com.android.internal.R.styleable.AnticipateOvershootInterpolator_tension;
import static com.android.internal.R.styleable.AnticipateOvershootInterpolator;
import static com.android.internal.R.styleable.AnticipateOvershootInterpolator;
@@ -27,7 +32,8 @@ import static com.android.internal.R.styleable.AnticipateOvershootInterpolator;
 * An interpolator where the change starts backward then flings forward and overshoots
 * An interpolator where the change starts backward then flings forward and overshoots
 * the target value and finally goes back to the final value.
 * the target value and finally goes back to the final value.
 */
 */
public class AnticipateOvershootInterpolator implements Interpolator {
@HasNativeInterpolator
public class AnticipateOvershootInterpolator implements Interpolator, NativeInterpolatorFactory {
    private final float mTension;
    private final float mTension;


    public AnticipateOvershootInterpolator() {
    public AnticipateOvershootInterpolator() {
@@ -80,4 +86,10 @@ public class AnticipateOvershootInterpolator implements Interpolator {
        if (t < 0.5f) return 0.5f * a(t * 2.0f, mTension);
        if (t < 0.5f) return 0.5f * a(t * 2.0f, mTension);
        else return 0.5f * (o(t * 2.0f - 2.0f, mTension) + 2.0f);
        else return 0.5f * (o(t * 2.0f - 2.0f, mTension) + 2.0f);
    }
    }

    /** @hide */
    @Override
    public long createNativeInterpolator() {
        return NativeInterpolatorFactoryHelper.createAnticipateOvershootInterpolator(mTension);
    }
}
}
+12 −1
Original line number Original line Diff line number Diff line
@@ -19,10 +19,15 @@ package android.view.animation;
import android.content.Context;
import android.content.Context;
import android.util.AttributeSet;
import android.util.AttributeSet;


import com.android.internal.view.animation.HasNativeInterpolator;
import com.android.internal.view.animation.NativeInterpolatorFactory;
import com.android.internal.view.animation.NativeInterpolatorFactoryHelper;

/**
/**
 * An interpolator where the change bounces at the end.
 * An interpolator where the change bounces at the end.
 */
 */
public class BounceInterpolator implements Interpolator {
@HasNativeInterpolator
public class BounceInterpolator implements Interpolator, NativeInterpolatorFactory {
    public BounceInterpolator() {
    public BounceInterpolator() {
    }
    }


@@ -47,4 +52,10 @@ public class BounceInterpolator implements Interpolator {
        else if (t < 0.9644f) return bounce(t - 0.8526f) + 0.9f;
        else if (t < 0.9644f) return bounce(t - 0.8526f) + 0.9f;
        else return bounce(t - 1.0435f) + 0.95f;
        else return bounce(t - 1.0435f) + 0.95f;
    }
    }

    /** @hide */
    @Override
    public long createNativeInterpolator() {
        return NativeInterpolatorFactoryHelper.createBounceInterpolator();
    }
}
}
 No newline at end of file
+12 −1
Original line number Original line Diff line number Diff line
@@ -20,12 +20,17 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.AttributeSet;


import com.android.internal.view.animation.HasNativeInterpolator;
import com.android.internal.view.animation.NativeInterpolatorFactory;
import com.android.internal.view.animation.NativeInterpolatorFactoryHelper;

/**
/**
 * Repeats the animation for a specified number of cycles. The
 * Repeats the animation for a specified number of cycles. The
 * rate of change follows a sinusoidal pattern.
 * rate of change follows a sinusoidal pattern.
 *
 *
 */
 */
public class CycleInterpolator implements Interpolator {
@HasNativeInterpolator
public class CycleInterpolator implements Interpolator, NativeInterpolatorFactory {
    public CycleInterpolator(float cycles) {
    public CycleInterpolator(float cycles) {
        mCycles = cycles;
        mCycles = cycles;
    }
    }
@@ -44,4 +49,10 @@ public class CycleInterpolator implements Interpolator {
    }
    }
    
    
    private float mCycles;
    private float mCycles;

    /** @hide */
    @Override
    public long createNativeInterpolator() {
        return NativeInterpolatorFactoryHelper.createCycleInterpolator(mCycles);
    }
}
}
Loading