├── .gitignore ├── README.md ├── art ├── FPSAnimator1.gif ├── easing.png └── expo.png ├── build.gradle ├── ei ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── daasuu │ │ └── ei │ │ ├── Ease.java │ │ ├── EasingInterpolator.java │ │ └── EasingProvider.java │ └── res │ └── values │ └── strings.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── jitpack.yml ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── daasuu │ │ └── easinginterpolator │ │ ├── EasingGraphView.java │ │ └── MainActivity.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | 4 | # built application files 5 | *.apk 6 | *.ap_ 7 | 8 | # files for the dex VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | 14 | # gradle files 15 | .gradle 16 | 17 | # IntelliJ 18 | .idea 19 | *.iml 20 | 21 | # generated files 22 | bin/ 23 | gen/ 24 | obj/ 25 | apk/ 26 | target/ 27 | build/ 28 | app/libs/**/*.java 29 | 30 | # Local configuration file (sdk path, etc) 31 | local.properties 32 | *crashlytics-build.properties 33 | *com_crashlytics_export_strings.xml 34 | 35 | # Proguard folder generated by Eclipse 36 | proguard/ 37 | 38 | mapping.txt 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EasingInterpolator 2 | [![Platform](https://img.shields.io/badge/platform-android-green.svg)](http://developer.android.com/index.html) 3 | 4 | [![API](https://img.shields.io/badge/API-14%2B-yellow.svg?style=flat)](https://android-arsenal.com/api?level=14) 5 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-EasingInterpolator-green.svg?style=true)](http://android-arsenal.com/details/1/3300) 6 | 7 | Thirty-one different easing animation interpolators for Android.
8 | It does not use the standard 4 param ease signature. Instead it uses a single param which indicates the current linear ratio (0 to 1) of the tween. 9 | 10 | # Gradle 11 | Step 1. Add the JitPack repository to your build file 12 | ```groovy 13 | allprojects { 14 | repositories { 15 | ... 16 | maven { url 'https://jitpack.io' } 17 | } 18 | } 19 | ``` 20 | Step 2. Add the dependency 21 | ```groovy 22 | dependencies { 23 | implementation 'com.github.MasayukiSuda:EasingInterpolator:v1.3.2' 24 | } 25 | ``` 26 | 27 | # Usage 28 | ```JAVA 29 | 30 | ValueAnimator valueAnimator = new ValueAnimator(); 31 | valueAnimator.setInterpolator(new EasingInterpolator(Ease.CUBIC_IN)); 32 | valueAnimator.start(); 33 | 34 | ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationY", 0, 300); 35 | animator.setInterpolator(new EasingInterpolator(Ease.ELASTIC_IN_OUT))); 36 | animator.start(); 37 | 38 | ``` 39 | # Easing Graphs 40 | 41 | 42 | 43 | 44 | # ProGuard 45 | ``` 46 | -keep class com.daasuu.** { *; } 47 | ``` 48 | 49 | ## License 50 | 51 | Copyright 2015 MasayukiSuda 52 | 53 | MIT License 54 | 55 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 56 | 57 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 58 | 59 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 60 | 61 | 62 | -------------------------------------------------------------------------------- /art/FPSAnimator1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasayukiSuda/EasingInterpolator/1cc83aeaf69c53a0013c1c8f59de7b6f200b359d/art/FPSAnimator1.gif -------------------------------------------------------------------------------- /art/easing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasayukiSuda/EasingInterpolator/1cc83aeaf69c53a0013c1c8f59de7b6f200b359d/art/easing.png -------------------------------------------------------------------------------- /art/expo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasayukiSuda/EasingInterpolator/1cc83aeaf69c53a0013c1c8f59de7b6f200b359d/art/expo.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | google() 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.0.3' 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | google() 18 | mavenCentral() 19 | } 20 | } 21 | 22 | task clean(type: Delete) { 23 | delete rootProject.buildDir 24 | } 25 | -------------------------------------------------------------------------------- /ei/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /ei/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'maven-publish' 3 | 4 | android { 5 | compileSdkVersion COMPILE_SDK_VERSION as int 6 | buildToolsVersion BUILD_TOOLS_VERSION 7 | 8 | defaultConfig { 9 | minSdkVersion COMPILE_MIN_SDK_VERSION as int 10 | targetSdkVersion COMPILE_SDK_VERSION as int 11 | } 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 16 | } 17 | } 18 | lintOptions { 19 | abortOnError false 20 | } 21 | } 22 | 23 | dependencies { 24 | implementation fileTree(dir: 'libs', include: ['*.jar']) 25 | implementation 'androidx.appcompat:appcompat:1.3.1' 26 | } 27 | 28 | afterEvaluate { 29 | publishing { 30 | publications { 31 | // Creates a Maven publication called "release". 32 | release(MavenPublication) { 33 | // Applies the component for the release build variant. 34 | from components.release 35 | 36 | // You can then customize attributes of the publication as shown below. 37 | groupId = 'com.daasuu.ei' 38 | artifactId = 'easinginterpolator' 39 | version = '1.3.2' 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ei/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/sudamasayuki/Documents/workspace/adt-bundle-mac-x86_64-20140321/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /ei/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ei/src/main/java/com/daasuu/ei/Ease.java: -------------------------------------------------------------------------------- 1 | package com.daasuu.ei; 2 | 3 | /** 4 | * The Easing class provides a collection of ease functions. It does not use the standard 4 param 5 | * ease signature. Instead it uses a single param which indicates the current linear ratio (0 to 1) of the tween. 6 | */ 7 | public enum Ease { 8 | LINEAR, 9 | QUAD_IN, 10 | QUAD_OUT, 11 | QUAD_IN_OUT, 12 | CUBIC_IN, 13 | CUBIC_OUT, 14 | CUBIC_IN_OUT, 15 | QUART_IN, 16 | QUART_OUT, 17 | QUART_IN_OUT, 18 | QUINT_IN, 19 | QUINT_OUT, 20 | QUINT_IN_OUT, 21 | SINE_IN, 22 | SINE_OUT, 23 | SINE_IN_OUT, 24 | BACK_IN, 25 | BACK_OUT, 26 | BACK_IN_OUT, 27 | CIRC_IN, 28 | CIRC_OUT, 29 | CIRC_IN_OUT, 30 | BOUNCE_IN, 31 | BOUNCE_OUT, 32 | BOUNCE_IN_OUT, 33 | ELASTIC_IN, 34 | ELASTIC_OUT, 35 | ELASTIC_IN_OUT, 36 | EASE_IN_EXPO, 37 | EASE_OUT_EXPO, 38 | EASE_IN_OUT_EXPO 39 | } 40 | -------------------------------------------------------------------------------- /ei/src/main/java/com/daasuu/ei/EasingInterpolator.java: -------------------------------------------------------------------------------- 1 | package com.daasuu.ei; 2 | 3 | import android.view.animation.Interpolator; 4 | 5 | import androidx.annotation.NonNull; 6 | 7 | /** 8 | * The Easing class provides a collection of ease functions. It does not use the standard 4 param 9 | * ease signature. Instead it uses a single param which indicates the current linear ratio (0 to 1) of the tween. 10 | */ 11 | public class EasingInterpolator implements Interpolator { 12 | 13 | private final Ease ease; 14 | 15 | public EasingInterpolator(@NonNull Ease ease) { 16 | this.ease = ease; 17 | } 18 | 19 | @Override 20 | public float getInterpolation(float input) { 21 | return EasingProvider.get(this.ease, input); 22 | } 23 | 24 | public Ease getEase() { 25 | return ease; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ei/src/main/java/com/daasuu/ei/EasingProvider.java: -------------------------------------------------------------------------------- 1 | package com.daasuu.ei; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | /** 6 | * The Easing class provides a collection of ease functions. It does not use the standard 4 param 7 | * ease signature. Instead it uses a single param which indicates the current linear ratio (0 to 1) of the tween. 8 | */ 9 | class EasingProvider { 10 | /** 11 | * @param ease Easing type 12 | * @param elapsedTimeRate Elapsed time / Total time 13 | * @return easedValue 14 | */ 15 | static float get(@NonNull Ease ease, float elapsedTimeRate) { 16 | switch (ease) { 17 | case LINEAR: 18 | return elapsedTimeRate; 19 | case QUAD_IN: 20 | return getPowIn(elapsedTimeRate, 2); 21 | case QUAD_OUT: 22 | return getPowOut(elapsedTimeRate, 2); 23 | case QUAD_IN_OUT: 24 | return getPowInOut(elapsedTimeRate, 2); 25 | case CUBIC_IN: 26 | return getPowIn(elapsedTimeRate, 3); 27 | case CUBIC_OUT: 28 | return getPowOut(elapsedTimeRate, 3); 29 | case CUBIC_IN_OUT: 30 | return getPowInOut(elapsedTimeRate, 3); 31 | case QUART_IN: 32 | return getPowIn(elapsedTimeRate, 4); 33 | case QUART_OUT: 34 | return getPowOut(elapsedTimeRate, 4); 35 | case QUART_IN_OUT: 36 | return getPowInOut(elapsedTimeRate, 4); 37 | case QUINT_IN: 38 | return getPowIn(elapsedTimeRate, 5); 39 | case QUINT_OUT: 40 | return getPowOut(elapsedTimeRate, 5); 41 | case QUINT_IN_OUT: 42 | return getPowInOut(elapsedTimeRate, 5); 43 | case SINE_IN: 44 | return (float) (1f - Math.cos(elapsedTimeRate * Math.PI / 2f)); 45 | case SINE_OUT: 46 | return (float) Math.sin(elapsedTimeRate * Math.PI / 2f); 47 | case SINE_IN_OUT: 48 | return (float) (-0.5f * (Math.cos(Math.PI * elapsedTimeRate) - 1f)); 49 | case BACK_IN: 50 | return (float) (elapsedTimeRate * elapsedTimeRate * ((1.7 + 1f) * elapsedTimeRate - 1.7)); 51 | case BACK_OUT: 52 | return (float) (--elapsedTimeRate * elapsedTimeRate * ((1.7 + 1f) * elapsedTimeRate + 1.7) + 1f); 53 | case BACK_IN_OUT: 54 | return getBackInOut(elapsedTimeRate, 1.7f); 55 | case CIRC_IN: 56 | return (float) -(Math.sqrt(1f - elapsedTimeRate * elapsedTimeRate) - 1); 57 | case CIRC_OUT: 58 | return (float) Math.sqrt(1f - (--elapsedTimeRate) * elapsedTimeRate); 59 | case CIRC_IN_OUT: 60 | if ((elapsedTimeRate *= 2f) < 1f) { 61 | return (float) (-0.5f * (Math.sqrt(1f - elapsedTimeRate * elapsedTimeRate) - 1f)); 62 | } 63 | return (float) (0.5f * (Math.sqrt(1f - (elapsedTimeRate -= 2f) * elapsedTimeRate) + 1f)); 64 | case BOUNCE_IN: 65 | return getBounceIn(elapsedTimeRate); 66 | case BOUNCE_OUT: 67 | return getBounceOut(elapsedTimeRate); 68 | case BOUNCE_IN_OUT: 69 | if (elapsedTimeRate < 0.5f) { 70 | return getBounceIn(elapsedTimeRate * 2f) * 0.5f; 71 | } 72 | return getBounceOut(elapsedTimeRate * 2f - 1f) * 0.5f + 0.5f; 73 | case ELASTIC_IN: 74 | return getElasticIn(elapsedTimeRate, 1, 0.3); 75 | 76 | case ELASTIC_OUT: 77 | return getElasticOut(elapsedTimeRate, 1, 0.3); 78 | 79 | case ELASTIC_IN_OUT: 80 | return getElasticInOut(elapsedTimeRate, 1, 0.45); 81 | 82 | case EASE_IN_EXPO: { 83 | return (float) Math.pow(2, 10 * (elapsedTimeRate - 1)); 84 | } 85 | case EASE_OUT_EXPO: { 86 | return (float) -Math.pow(2, -10 * elapsedTimeRate) + 1; 87 | } 88 | case EASE_IN_OUT_EXPO: { 89 | if ((elapsedTimeRate *= 2) < 1) { 90 | return (float) Math.pow(2, 10 * (elapsedTimeRate - 1)) * 0.5f; 91 | } 92 | return (float) (-Math.pow(2, -10 * --elapsedTimeRate) + 2f) * 0.5f; 93 | } 94 | default: 95 | return elapsedTimeRate; 96 | 97 | } 98 | 99 | } 100 | 101 | /** 102 | * @param elapsedTimeRate Elapsed time / Total time 103 | * @param pow pow The exponent to use (ex. 3 would return a cubic ease). 104 | * @return easedValue 105 | */ 106 | private static float getPowIn(float elapsedTimeRate, double pow) { 107 | return (float) Math.pow(elapsedTimeRate, pow); 108 | } 109 | 110 | /** 111 | * @param elapsedTimeRate Elapsed time / Total time 112 | * @param pow pow The exponent to use (ex. 3 would return a cubic ease). 113 | * @return easedValue 114 | */ 115 | private static float getPowOut(float elapsedTimeRate, double pow) { 116 | return (float) ((float) 1 - Math.pow(1 - elapsedTimeRate, pow)); 117 | } 118 | 119 | /** 120 | * @param elapsedTimeRate Elapsed time / Total time 121 | * @param pow pow The exponent to use (ex. 3 would return a cubic ease). 122 | * @return easedValue 123 | */ 124 | private static float getPowInOut(float elapsedTimeRate, double pow) { 125 | if ((elapsedTimeRate *= 2) < 1) { 126 | return (float) (0.5 * Math.pow(elapsedTimeRate, pow)); 127 | } 128 | 129 | return (float) (1 - 0.5 * Math.abs(Math.pow(2 - elapsedTimeRate, pow))); 130 | } 131 | 132 | /** 133 | * @param elapsedTimeRate Elapsed time / Total time 134 | * @param amount amount The strength of the ease. 135 | * @return easedValue 136 | */ 137 | private static float getBackInOut(float elapsedTimeRate, float amount) { 138 | amount *= 1.525; 139 | if ((elapsedTimeRate *= 2) < 1) { 140 | return (float) (0.5 * (elapsedTimeRate * elapsedTimeRate * ((amount + 1) * elapsedTimeRate - amount))); 141 | } 142 | return (float) (0.5 * ((elapsedTimeRate -= 2) * elapsedTimeRate * ((amount + 1) * elapsedTimeRate + amount) + 2)); 143 | } 144 | 145 | /** 146 | * @param elapsedTimeRate Elapsed time / Total time 147 | * @return easedValue 148 | */ 149 | private static float getBounceIn(float elapsedTimeRate) { 150 | return 1f - getBounceOut(1f - elapsedTimeRate); 151 | } 152 | 153 | /** 154 | * @param elapsedTimeRate Elapsed time / Total time 155 | * @return easedValue 156 | */ 157 | private static float getBounceOut(float elapsedTimeRate) { 158 | if (elapsedTimeRate < 1 / 2.75) { 159 | return (float) (7.5625 * elapsedTimeRate * elapsedTimeRate); 160 | } else if (elapsedTimeRate < 2 / 2.75) { 161 | return (float) (7.5625 * (elapsedTimeRate -= 1.5 / 2.75) * elapsedTimeRate + 0.75); 162 | } else if (elapsedTimeRate < 2.5 / 2.75) { 163 | return (float) (7.5625 * (elapsedTimeRate -= 2.25 / 2.75) * elapsedTimeRate + 0.9375); 164 | } else { 165 | return (float) (7.5625 * (elapsedTimeRate -= 2.625 / 2.75) * elapsedTimeRate + 0.984375); 166 | } 167 | } 168 | 169 | /** 170 | * @param elapsedTimeRate Elapsed time / Total time 171 | * @param amplitude Amplitude of easing 172 | * @param period Animation of period 173 | * @return easedValue 174 | */ 175 | private static float getElasticIn(float elapsedTimeRate, double amplitude, double period) { 176 | if (elapsedTimeRate == 0 || elapsedTimeRate == 1) return elapsedTimeRate; 177 | double pi2 = Math.PI * 2; 178 | double s = period / pi2 * Math.asin(1 / amplitude); 179 | return (float) -(amplitude * Math.pow(2f, 10f * (elapsedTimeRate -= 1f)) * Math.sin((elapsedTimeRate - s) * pi2 / period)); 180 | } 181 | 182 | /** 183 | * @param elapsedTimeRate Elapsed time / Total time 184 | * @param amplitude Amplitude of easing 185 | * @param period Animation of period 186 | * @return easedValue 187 | */ 188 | private static float getElasticOut(float elapsedTimeRate, double amplitude, double period) { 189 | if (elapsedTimeRate == 0 || elapsedTimeRate == 1) return elapsedTimeRate; 190 | 191 | double pi2 = Math.PI * 2; 192 | double s = period / pi2 * Math.asin(1 / amplitude); 193 | return (float) (amplitude * Math.pow(2, -10 * elapsedTimeRate) * Math.sin((elapsedTimeRate - s) * pi2 / period) + 1); 194 | } 195 | 196 | /** 197 | * @param elapsedTimeRate Elapsed time / Total time 198 | * @param amplitude Amplitude of easing 199 | * @param period Animation of period 200 | * @return easedValue 201 | */ 202 | private static float getElasticInOut(float elapsedTimeRate, double amplitude, double period) { 203 | double pi2 = Math.PI * 2; 204 | 205 | double s = period / pi2 * Math.asin(1 / amplitude); 206 | if ((elapsedTimeRate *= 2) < 1) { 207 | return (float) (-0.5f * (amplitude * Math.pow(2, 10 * (elapsedTimeRate -= 1f)) * Math.sin((elapsedTimeRate - s) * pi2 / period))); 208 | } 209 | return (float) (amplitude * Math.pow(2, -10 * (elapsedTimeRate -= 1)) * Math.sin((elapsedTimeRate - s) * pi2 / period) * 0.5 + 1); 210 | 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /ei/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Ei 3 | 4 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | VERSION_CODE=1 2 | BUILD_TOOLS_VERSION=30.0.3 3 | COMPILE_SDK_VERSION=31 4 | COMPILE_MIN_SDK_VERSION=14 5 | android.useAndroidX=true 6 | android.enableJetifier=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasayukiSuda/EasingInterpolator/1cc83aeaf69c53a0013c1c8f59de7b6f200b359d/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Sep 15 11:22:38 JST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | jdk: 2 | - openjdk11 -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion COMPILE_SDK_VERSION as int 5 | buildToolsVersion BUILD_TOOLS_VERSION 6 | 7 | defaultConfig { 8 | applicationId "com.daasuu.easinginterpolator" 9 | minSdkVersion COMPILE_MIN_SDK_VERSION as int 10 | targetSdkVersion COMPILE_SDK_VERSION as int 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | implementation 'androidx.appcompat:appcompat:1.3.1' 25 | implementation project(':ei') 26 | } 27 | -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/sudamasayuki/Documents/workspace/adt-bundle-mac-x86_64-20140321/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /sample/src/main/java/com/daasuu/easinginterpolator/EasingGraphView.java: -------------------------------------------------------------------------------- 1 | package com.daasuu.easinginterpolator; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.graphics.PointF; 8 | import android.util.AttributeSet; 9 | import android.util.DisplayMetrics; 10 | import android.widget.FrameLayout; 11 | 12 | import com.daasuu.ei.Ease; 13 | import com.daasuu.ei.EasingInterpolator; 14 | 15 | /** 16 | * Created by sudamasayuki on 16/03/19. 17 | */ 18 | public class EasingGraphView extends FrameLayout { 19 | 20 | private Paint mPaint = new Paint(); 21 | private Paint mFramePaint = new Paint(); 22 | private Paint mTextPaint = new Paint(); 23 | 24 | private EasingInterpolator easingInterpolator; 25 | private float mAdjustTextMesureY = -1; 26 | 27 | private float dpSize; 28 | 29 | private final int loopSize = 100; 30 | 31 | public EasingGraphView(Context context) { 32 | this(context, null, 0); 33 | } 34 | 35 | public EasingGraphView(Context context, Ease ease) { 36 | this(context, null, 0); 37 | easingInterpolator = new EasingInterpolator(ease); 38 | } 39 | 40 | public EasingGraphView(Context context, AttributeSet attrs) { 41 | this(context, attrs, 0); 42 | } 43 | 44 | public EasingGraphView(Context context, AttributeSet attrs, int defStyleAttr) { 45 | super(context, attrs, defStyleAttr); 46 | 47 | mPaint.setColor(Color.BLUE); 48 | mPaint.setAntiAlias(true); 49 | 50 | mFramePaint.setColor(Color.BLUE); 51 | mFramePaint.setAntiAlias(true); 52 | mFramePaint.setStyle(Paint.Style.STROKE); 53 | 54 | dpSize = convertDpToPixel(1, context); 55 | 56 | mTextPaint.setTextSize(convertDpToPixel(12, context)); 57 | mAdjustTextMesureY = mTextPaint.getTextSize(); 58 | } 59 | 60 | 61 | @Override 62 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 63 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 64 | setMeasuredDimension(110 * (int) dpSize, 180 * (int) dpSize); 65 | } 66 | 67 | private static float convertDpToPixel(float dp, Context context) { 68 | DisplayMetrics metrics = context.getResources().getDisplayMetrics(); 69 | return dp * (metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT); 70 | } 71 | 72 | @Override 73 | protected void dispatchDraw(Canvas canvas) { 74 | super.dispatchDraw(canvas); 75 | 76 | if (easingInterpolator == null) { 77 | easingInterpolator = new EasingInterpolator(Ease.ELASTIC_IN_OUT); 78 | } 79 | 80 | int xWidth = (int) mTextPaint.measureText(easingInterpolator.getEase().name()); 81 | float x = (loopSize * dpSize - xWidth) / 2f; 82 | if (x < 0) { 83 | x = 0; 84 | } 85 | canvas.drawText(easingInterpolator.getEase().name(), x, mAdjustTextMesureY, mTextPaint); 86 | 87 | 88 | PointF points[] = new PointF[loopSize]; 89 | for (int i = 0; i < loopSize; i++) { 90 | points[i] = new PointF(); 91 | points[i].x = i * dpSize; 92 | points[i].y = (loopSize - easingInterpolator.getInterpolation((float) i / loopSize) * loopSize) * dpSize; 93 | } 94 | 95 | canvas.save(); 96 | { 97 | canvas.translate(0, 40 * dpSize); 98 | for (int i = 0, n = loopSize - 1; i < n; i++) { 99 | canvas.drawLine(points[i].x, points[i].y, 100 | points[i + 1].x, points[i + 1].y, mPaint); 101 | } 102 | canvas.drawRect(0, 0, loopSize * dpSize, loopSize * dpSize, mFramePaint); 103 | } 104 | canvas.restore(); 105 | 106 | } 107 | 108 | 109 | } 110 | -------------------------------------------------------------------------------- /sample/src/main/java/com/daasuu/easinginterpolator/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.daasuu.easinginterpolator; 2 | 3 | import android.os.Bundle; 4 | import android.widget.LinearLayout; 5 | 6 | import com.daasuu.ei.Ease; 7 | 8 | import androidx.appcompat.app.AppCompatActivity; 9 | 10 | public class MainActivity extends AppCompatActivity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_main); 16 | 17 | LinearLayout flowLayout = findViewById(R.id.layout_flow); 18 | 19 | for (Ease ease : Ease.values()) { 20 | flowLayout.addView(new EasingGraphView(this, ease)); 21 | } 22 | 23 | // ObjectAnimator animator = ObjectAnimator.ofFloat(flowLayout, "translationY", 0, -300); 24 | // animator.setInterpolator(new EasingInterpolator(Ease.EASE_IN_OUT_EXPO)); 25 | // animator.setDuration(5000); 26 | // animator.start(); 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasayukiSuda/EasingInterpolator/1cc83aeaf69c53a0013c1c8f59de7b6f200b359d/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasayukiSuda/EasingInterpolator/1cc83aeaf69c53a0013c1c8f59de7b6f200b359d/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasayukiSuda/EasingInterpolator/1cc83aeaf69c53a0013c1c8f59de7b6f200b359d/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasayukiSuda/EasingInterpolator/1cc83aeaf69c53a0013c1c8f59de7b6f200b359d/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MasayukiSuda/EasingInterpolator/1cc83aeaf69c53a0013c1c8f59de7b6f200b359d/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | EasingInterpolator 3 | 4 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':ei' 2 | --------------------------------------------------------------------------------