1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.camera.ui.motion; 18 19 /** 20 * Predefined material curves and animations. 21 */ 22 public class UnitCurves { 23 public static final UnitCurve FAST_OUT_SLOW_IN = new UnitBezier(0.4f, 0.0f, 0.2f, 1.0f); 24 public static final UnitCurve LINEAR_OUT_SLOW_IN = new UnitBezier(0.0f, 0.0f, 0.2f, 1.0f); 25 public static final UnitCurve FAST_OUT_LINEAR_IN = new UnitBezier(0.4f, 0.0f, 1.0f, 1.0f); 26 public static final UnitCurve LINEAR = new UnitBezier(0.0f, 0.0f, 1.0f, 1.0f); 27 28 /** 29 * Given two curves (from and to) and a time along the from curve, compute 30 * the time at t, and find a t along the 'toCurve' that will produce the 31 * same output. This is useful when interpolating between two different curves 32 * when the animation is not at the beginning or end. 33 * 34 * @param enterCurve the curve to compute the value from 35 * @param exitCurve the curve to find a time t on that matches output of 36 * enterCurve at T. 37 * @param t the time at which to compute the value (0..1) 38 * @return the time along the exitCurve. 39 */ mapEnterCurveToExitCurveAtT(UnitCurve enterCurve, UnitCurve exitCurve, float t)40 public static float mapEnterCurveToExitCurveAtT(UnitCurve enterCurve, UnitCurve exitCurve, 41 float t) { 42 return exitCurve.tAt(1 - enterCurve.valueAt(t)); 43 } 44 } 45