Easing tests.
This commit is contained in:
26
include/dawn/animation/easing.h
Normal file
26
include/dawn/animation/easing.h
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
|
||||
/**
|
||||
* Returns the ease time for a given real time duration span.
|
||||
* @param start At what point in time the animation started
|
||||
* @param current The current point in time the animation is at.
|
||||
* @param duration The total duration on the animation.
|
||||
* @returns The easing time (0-1 time) that the animation is at.
|
||||
*/
|
||||
#define easeTimeToEase(start, current, duration) ((current-start)/duration)
|
||||
|
||||
#define easeLinear(t) t
|
||||
|
||||
#define easeInQuad(t) t*t
|
||||
#define easeOutQuad(t) t*(2-t)
|
||||
#define easeInOutQuad(t) (t < .5 ? 2*t*t : -1+(4-2*t)*t)
|
||||
|
||||
#define easeInCubic(t) t*t*t
|
||||
#define easeOutCubic(t) t*(t-1)*(t-1)+1
|
@ -6,6 +6,9 @@
|
||||
#pragma once
|
||||
#include "libs.h"
|
||||
|
||||
// Animation
|
||||
#include "animation/easing.h"
|
||||
|
||||
// Display / Rendering
|
||||
#include "display/debug/grid.h"
|
||||
|
||||
|
Reference in New Issue
Block a user