@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static Interpolator create(float controlX1, float controlY1, float controlX2, float controlY2) { return new PathInterpolator(controlX1, controlY1, controlX2, controlY2); } }
private static int[] getOutputPointsForNewerDevices(Point[] knots) { Point[] controlPoints = calculateControlPoints(knots); Path path = new Path(); path.moveTo(0, 0); path.lineTo(knots[0].x / 255.0f, knots[0].y / 255.0f); path.moveTo(knots[0].x / 255.0f, knots[0].y / 255.0f); for (int index = 1; index < knots.length; index++) { path.quadTo( controlPoints[index - 1].x / 255.0f, controlPoints[index - 1].y / 255.0f, knots[index].x / 255.0f, knots[index].y / 255.0f ); path.moveTo(knots[index].x / 255.0f, knots[index].y / 255.0f); } path.lineTo(1, 1); path.moveTo(1, 1); float[] allPoints = new float[256]; for (int x = 0; x < 256; x++) { PathInterpolator pathInterpolator = new PathInterpolator(path); allPoints[x] = 255.0f * pathInterpolator.getInterpolation((float) x / 255.0f); } allPoints[0] = knots[0].y; allPoints[255] = knots[knots.length - 1].y; return validateCurve(allPoints); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static Interpolator create(Path path) { return new PathInterpolator(path); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static Interpolator create(float controlX, float controlY) { return new PathInterpolator(controlX, controlY); }
private void setupPathInterpolator() { if (mQuadraticPath) { mInterpolator = new PathInterpolator(mCx1, mCy1); if (mPathCallback != null) { mPathCallback.onControlPoint1Moved(mCx1, mCy1); } } else if (mCubicPath) { mInterpolator = new PathInterpolator(mCx1, mCy1, mCx2, mCy2); if (mPathCallback != null) { mPathCallback.onControlPoint1Moved(mCx1, mCy1); mPathCallback.onControlPoint2Moved(mCx2, mCy2); } } invalidate(); }
private Interpolator getInterpolator(float startGradient, float velocityFactor) { if (startGradient != mCachedStartGradient || velocityFactor != mCachedVelocityFactor) { float speedup = mSpeedUpFactor * (1.0f - velocityFactor); mInterpolator = new PathInterpolator(speedup, speedup * startGradient, mLinearOutSlowInX2, mY2); mCachedStartGradient = startGradient; mCachedVelocityFactor = velocityFactor; } return mInterpolator; }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) Interpolator createInterpolator(Context c) { if (null != controlX2 && null != controlY2) { return new PathInterpolator(controlX1, controlY1, controlX2, controlY2); } else { return new PathInterpolator(controlX1, controlY1); } } }
private Interpolator createCheckInterpolatorCompat() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return new PathInterpolator(0.755F, 0.05F, 0.855F, 0.06F); } else { return new AccelerateInterpolator(); } }
public static Interpolator create(float controlX1, float controlY1, float controlX2, float controlY2) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return new PathInterpolator(controlX1, controlY1, controlX2, controlY2); } return new PathInterpolatorBase(controlX1, controlY1, controlX2, controlY2); }
private AnimatorProperties getDismissingProperties(float currValue, float endValue, float velocity, float maxDistance) { float maxLengthSeconds = (float) (mMaxLengthSeconds * Math.pow(Math.abs(endValue - currValue) / maxDistance, 0.5f)); float diff = Math.abs(endValue - currValue); float velAbs = Math.abs(velocity); float y2 = calculateLinearOutFasterInY2(velAbs); float startGradient = y2 / LINEAR_OUT_FASTER_IN_X2; Interpolator mLinearOutFasterIn = new PathInterpolator(0, 0, LINEAR_OUT_FASTER_IN_X2, y2); float durationSeconds = startGradient * diff / velAbs; if (durationSeconds <= maxLengthSeconds) { mAnimatorProperties.interpolator = mLinearOutFasterIn; } else if (velAbs >= mMinVelocityPxPerSecond) { // Cross fade between linear-out-faster-in and linear interpolator with current // velocity. durationSeconds = maxLengthSeconds; VelocityInterpolator velocityInterpolator = new VelocityInterpolator(durationSeconds, velAbs, diff); InterpolatorInterpolator superInterpolator = new InterpolatorInterpolator( velocityInterpolator, mLinearOutFasterIn, Interpolators.LINEAR_OUT_SLOW_IN); mAnimatorProperties.interpolator = superInterpolator; } else { // Just use a normal interpolator which doesn't take the velocity into account. durationSeconds = maxLengthSeconds; mAnimatorProperties.interpolator = Interpolators.FAST_OUT_LINEAR_IN; } mAnimatorProperties.duration = (long) (durationSeconds * 1000); return mAnimatorProperties; }
aset.playSequentially(va1, va2, va3); aset.setDuration(ANIMATION_DURATION_MS); aset.setInterpolator(new PathInterpolator(0.75f, 0.1f, 0.25f, 0.9f)); aset.start();