Skip to content

Commit

Permalink
Added Flash eases
Browse files Browse the repository at this point in the history
  • Loading branch information
Demigiant committed Oct 30, 2015
1 parent 2c22181 commit b58e6d0
Show file tree
Hide file tree
Showing 59 changed files with 302 additions and 9 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 5 additions & 1 deletion UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 5 additions & 1 deletion UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 6 additions & 1 deletion UnityTests.Unity5/Assets/_Tests/EaseCurves.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ void Setup()
} else {
img.GetComponentInChildren<Text>().text = easeType.ToString();
if (easeType == Ease.INTERNAL_Custom) tween.SetEase(easeCurve);
else tween.SetEase(easeType);
else{
float overshootOrAmplitude = easeType.ToString().IndexOf("Flash") == -1
? DOTween.defaultEaseOvershootOrAmplitude
: 16;
tween.SetEase(easeType, overshootOrAmplitude);
}
}
}
// Disable original image
Expand Down
Binary file modified UnityTests.Unity5/Assets/_Tests/EaseCurves.unity
Binary file not shown.
23 changes: 23 additions & 0 deletions UnityTests.Unity5/Assets/_Tests/EaseX.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using DG.Tweening;

public class EaseX : MonoBehaviour
{
public Image imgFlash, imgSmoothFlash;
public Color flashColor;
[Header("Tween Settings")]
public float duration = 2;
public Ease ease;
public float overshootOrAmplitude = 10;

public void Play()
{
DOTween.RewindAll();
DOTween.KillAll();

imgFlash.DOColor(flashColor, duration).SetEase(ease, overshootOrAmplitude);
imgSmoothFlash.DOColor(flashColor, duration).SetEase(ease, overshootOrAmplitude);
}
}
12 changes: 12 additions & 0 deletions UnityTests.Unity5/Assets/_Tests/EaseX.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added UnityTests.Unity5/Assets/_Tests/EaseX.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions UnityTests.Unity5/Assets/_Tests/EaseX.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 106 additions & 2 deletions _DOTween.Assembly/DOTween/Core/Easing/EaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
// This work is subject to the terms at http://dotween.demigiant.com/license.php
//
// =============================================================
// Contains Daniele Giardini's C# port of the easing equations created
// by Robert Penner - http://robertpenner.com/easing, see license below:
// Contains Daniele Giardini's C# port of the easing equations created by Robert Penner
// (all easing equations except for Flash, InFlash, OutFlash, InOutFlash,
// which use some parts of Robert Penner's equations but were created by Daniele Giardini)
// http://robertpenner.com/easing, see license below:
// =============================================================
//
// TERMS OF USE - EASING EQUATIONS
Expand Down Expand Up @@ -59,6 +61,9 @@ public static float Evaluate(Tween t, float time, float duration, float overshoo
/// </summary>
public static float Evaluate(Ease easeType, EaseFunction customEase, float time, float duration, float overshootOrAmplitude, float period)
{
float durationStep;
int dir;

switch (easeType) {
case Ease.Linear:
return time / duration;
Expand Down Expand Up @@ -162,6 +167,50 @@ public static float Evaluate(Ease easeType, EaseFunction customEase, float time,
case Ease.INTERNAL_Zero:
// 0 duration tween
return 1;

// Extra custom eases ////////////////////////////////////////////////////
case Ease.Flash:
durationStep = duration / overshootOrAmplitude;
dir = 1;
while (time > durationStep) {
time -= durationStep;
dir = -dir;
}
if (dir < 0) time -= durationStep;
return (time * dir) / durationStep;
case Ease.InFlash:
durationStep = duration / overshootOrAmplitude;
dir = 1;
while (time > durationStep) {
time -= durationStep;
dir = -dir;
}
if (dir < 0) time -= durationStep;
time = time * dir;
return (time /= durationStep) * time;
case Ease.OutFlash:
durationStep = duration / overshootOrAmplitude;
dir = 1;
while (time > durationStep) {
time -= durationStep;
dir = -dir;
}
if (dir < 0) time -= durationStep;
time = time * dir;
return -(time /= durationStep) * (time - 2);
case Ease.InOutFlash:
durationStep = duration / overshootOrAmplitude;
dir = 1;
while (time > durationStep) {
time -= durationStep;
dir = -dir;
}
if (dir < 0) time -= durationStep;
time = time * dir;
if ((time /= durationStep * 0.5f) < 1) return 0.5f * time * time;
return -0.5f * ((--time) * (time - 2) - 1);

// Default
default:
// OutQuad
return -(time /= duration) * (time - 2);
Expand All @@ -170,6 +219,9 @@ public static float Evaluate(Ease easeType, EaseFunction customEase, float time,

public static EaseFunction ToEaseFunction(Ease ease)
{
float durationStep;
int dir;

switch (ease) {
case Ease.Linear:
return (float time, float duration, float overshootOrAmplitude, float period) =>
Expand Down Expand Up @@ -310,6 +362,58 @@ public static EaseFunction ToEaseFunction(Ease ease)
case Ease.InOutBounce:
return (float time, float duration, float overshootOrAmplitude, float period) =>
Bounce.EaseInOut(time, duration, overshootOrAmplitude, period);

// Extra custom eases ////////////////////////////////////////////////////
case Ease.Flash:
return (float time, float duration, float overshootOrAmplitude, float period) => {
durationStep = duration / overshootOrAmplitude;
dir = 1;
while (time > durationStep) {
time -= durationStep;
dir = -dir;
}
if (dir < 0) time -= durationStep;
return (time * dir) / durationStep;
};
case Ease.InFlash:
return (float time, float duration, float overshootOrAmplitude, float period) => {
durationStep = duration / overshootOrAmplitude;
dir = 1;
while (time > durationStep) {
time -= durationStep;
dir = -dir;
}
if (dir < 0) time -= durationStep;
time = time * dir;
return (time /= durationStep) * time;
};
case Ease.OutFlash:
return (float time, float duration, float overshootOrAmplitude, float period) => {
durationStep = duration / overshootOrAmplitude;
dir = 1;
while (time > durationStep) {
time -= durationStep;
dir = -dir;
}
if (dir < 0) time -= durationStep;
time = time * dir;
return -(time /= durationStep) * (time - 2);
};
case Ease.InOutFlash:
return (float time, float duration, float overshootOrAmplitude, float period) => {
durationStep = duration / overshootOrAmplitude;
dir = 1;
while (time > durationStep) {
time -= durationStep;
dir = -dir;
}
if (dir < 0) time -= durationStep;
time = time * dir;
if ((time /= durationStep * 0.5f) < 1) return 0.5f * time * time;
return -0.5f * ((--time) * (time - 2) - 1);
};

// Default
default:
// OutQuad
return (float time, float duration, float overshootOrAmplitude, float period) => -(time /= duration) * (time - 2);
Expand Down
2 changes: 1 addition & 1 deletion _DOTween.Assembly/DOTween/DOTween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.1.030";
public static readonly string Version = "1.1.050";

///////////////////////////////////////////////
// Options ////////////////////////////////////
Expand Down
Loading

0 comments on commit b58e6d0

Please sign in to comment.