diff options
author | Paul Rohde <codelogic@google.com> | 2014-12-05 12:17:15 -0800 |
---|---|---|
committer | Bruno Martins <bgcngm@gmail.com> | 2018-11-20 12:32:17 +0000 |
commit | 6612b3c922aa9045342794f3d2ae19cf52ded79b (patch) | |
tree | e72cf8d7f00f6f8d592938755c922ab377ba10d0 /src/com/android/camera/ui/motion/InterpolateUtils.java | |
parent | b582d34c06a29df7bd2325f33b722b9961c0a68a (diff) | |
download | android_packages_apps_Snap-6612b3c922aa9045342794f3d2ae19cf52ded79b.tar.gz android_packages_apps_Snap-6612b3c922aa9045342794f3d2ae19cf52ded79b.tar.bz2 android_packages_apps_Snap-6612b3c922aa9045342794f3d2ae19cf52ded79b.zip |
Drop new focus indicator into Camera2.
* Create a new custom focus view that interacts with physical lens diopter changes.
* Replace all occurances of the old focus indicator with the new one.
Change-Id: Ia02646ce4d1eb059ecb8a1dfccc15dfc9c167e1b
Diffstat (limited to 'src/com/android/camera/ui/motion/InterpolateUtils.java')
-rw-r--r-- | src/com/android/camera/ui/motion/InterpolateUtils.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/com/android/camera/ui/motion/InterpolateUtils.java b/src/com/android/camera/ui/motion/InterpolateUtils.java new file mode 100644 index 000000000..3c3cd532f --- /dev/null +++ b/src/com/android/camera/ui/motion/InterpolateUtils.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.camera.ui.motion; + +/** + * Various static helper functions for interpolating between values. + */ +public class InterpolateUtils { + + private InterpolateUtils() { + } + + /** + * Linear interpolation from v0 to v1 as t goes from 0...1 + * + * @param v0 the value at t=0 + * @param v1 the value at t=1 + * @param t value in the range of 0 to 1. + * @return the value between v0 and v1 as a ratio between 0 and 1 defined by t. + */ + public static float lerp(float v0, float v1, float t) { + return v0 + t * (v1 - v0); + } + + /** + * Project a value that is within the in(Min/Max) number space into the to(Min/Max) number + * space. + * + * @param v value to scale into the 'to' number space. + * @param vMin min value of the values number space. + * @param vMax max value of the values number space. + * @param pMin min value of the projection number space. + * @param pMax max value of the projection number space. + * @return the ratio of the value in the source number space as a value in the to(Min/Max) + * number space. + */ + public static float scale(float v, float vMin, float vMax, float pMin, float pMax) { + return (pMax - pMin) * (v - vMin) / (vMax - vMin) + pMin; + } + + /** + * Value between 0 and 1 as a ratio between tBegin over tDuration + * with no upper bound. + */ + public static float unitRatio(long t, long tBegin, float tDuration) { + if (t <= tBegin) { + return 0.0f; + } + + return (t - tBegin) / tDuration; + } +} |