Dawn/src/dawn/display/animation/animation.h

38 lines
1.2 KiB
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../../libs.h"
/**
* Animation tool for converting 0-1 space into a 0-0.5 back to zero space. This
* is intended to make a "Forward then backwards" effect for animation. This
* method will not scale t.
* @param t Time in space to back and fourth on between 0 and 1.
* @returns Forward and backwards time. 0 to 0.5 are as such, 0.5 to 1 are from
* 0.5 to 0.
*/
float animForwardAndBackward(float t);
/**
* Animation tool for converting 0-1 space into a 0-1-0 space. Scaled version of
* animForwardAndBackward().
* @param t Time in space to back and fourth on between 0 and 1.
* @returns Forward and backwards time.
*/
float animForwardAndBackwardScaled(float t);
/**
* Returns the time scale (speed to multiply time range by) for a given frame
* time and frame count. E.g. 3 frames at 0.5 time each would have a time scale
* of 1.5.
*
* @param frames Frames to get the scale of.
* @param time Time to get the scale of.
* @return The time scale.
*/
float animTimeScaleFromFrameTime(int32_t frames, float time);