Skip to content

easings #

Easing Functions

This is a pure V module that provides easing functions calculation.

Usage

Use the animate function to apply an easing function over a range of numbers

module main

import vsl.easings

println(easings.animate(easings.bounce_ease_out, 0, 100, 100))

Credits

Based on the works of:

fn animate #

fn animate(easing EasingFn, from f64, to f64, frames int) []f64

animate returns []f64 of length "frames" using the easing function provided with lower and upper bounds as "from" and "to"

fn back_ease_in #

fn back_ease_in(p f64) f64

back_ease_in retracts the motion slightly before it begins to accelerate

fn back_ease_in_out #

fn back_ease_in_out(p f64) f64

back_ease_in_out retracts the motion slightly before it begins to accelerate, then retracts the motion slightly before it begins to decelerate afer a half

fn back_ease_out #

fn back_ease_out(p f64) f64

back_ease_out retracts the motion slightly before it begins to decelerate

fn bounce_ease_in #

fn bounce_ease_in(p f64) f64

bounce_ease_in creates a bouncing effect, then accelerates

fn bounce_ease_in_out #

fn bounce_ease_in_out(p f64) f64

bounce_ease_in_out creates a bouncing effect before it begins to accelerate, then it creates a bouncing effects again before it begins to decelerate

fn bounce_ease_out #

fn bounce_ease_out(p f64) f64

bounce_ease_out creates a bouncing effect, then decelerates

fn circular_ease_in #

fn circular_ease_in(p f64) f64

circular_ease_in accelerates using a circular function

fn circular_ease_in_out #

fn circular_ease_in_out(p f64) f64

circular_ease_in_out accelerates and decelerates using a circular function

fn circular_ease_out #

fn circular_ease_out(p f64) f64

circular_ease_out decelerates using a circular function

fn cubic_ease_in #

fn cubic_ease_in(p f64) f64

cubic_ease_in eases in with a power of 3

fn cubic_ease_in_out #

fn cubic_ease_in_out(p f64) f64

cubic_ease_in_out speeds up function's growth in a power of 3, then slows down after a half at the same rate

fn cubic_ease_out #

fn cubic_ease_out(p f64) f64

cubic_ease_out eases out with a power of 3

fn elastic_ease_in #

fn elastic_ease_in(p f64) f64

elastic_ease_in resembles a spring oscillating back and forth, then accelerates

fn elastic_ease_in_out #

fn elastic_ease_in_out(p f64) f64

elastic_ease_in_out resembles a spring oscillating back and forth before it begins to accelerate, then resembles a spring oscillating back and forth before it begins to decelerate afer a half

fn elastic_ease_out #

fn elastic_ease_out(p f64) f64

elastic_ease_out resembles a spring oscillating back and forth, then decelerates

fn exponential_ease_in #

fn exponential_ease_in(p f64) f64

exponential_ease_in accelerates using an exponential formula

fn exponential_ease_in_out #

fn exponential_ease_in_out(p f64) f64

exponential_ease_in_out accelerates and decelerates using an exponential formula

fn exponential_ease_out #

fn exponential_ease_out(p f64) f64

exponential_ease_out decelerates using an exponential formula

fn linear_interpolation #

fn linear_interpolation(p f64) f64

linear_interpolation is a method of curve fitting using linear polynomials to construct new data points within the range of a discrete set of known data points

fn quadratic_ease_in #

fn quadratic_ease_in(p f64) f64

quadratic_ease_in eases in with a power of 2

fn quadratic_ease_in_out #

fn quadratic_ease_in_out(p f64) f64

quadratic_easing_in_out speeds up function's growth in a power of 2, then slows down after a half at the same rate

fn quadratic_ease_out #

fn quadratic_ease_out(p f64) f64

quadratic_easing_eases out with a power of 2

fn quartic_ease_in #

fn quartic_ease_in(p f64) f64

quartic_ease_in eases in with a power of 4

fn quartic_ease_in_out #

fn quartic_ease_in_out(p f64) f64

quartic_ease_in_out speeds up function's growth in a power of 4, then slows down after a half at the same rate

fn quartic_ease_out #

fn quartic_ease_out(p f64) f64

quartic_ease_out eases out with a power of 4

fn quintic_ease_in #

fn quintic_ease_in(p f64) f64

quintic_ease_in eases in with a power of 5

fn quintic_ease_in_out #

fn quintic_ease_in_out(p f64) f64

quintic_ease_in_out speeds up function's growth in a power of 5, then slows down after a half at the same rate

fn quintic_ease_out #

fn quintic_ease_out(p f64) f64

quintic_ease_out eases out with a power of 5

fn sine_ease_in #

fn sine_ease_in(p f64) f64

sine_ease_in accelerates using a sine formula

fn sine_ease_in_out #

fn sine_ease_in_out(p f64) f64

sine_ease_in_out accelerates and decelerates using a sine formula

fn sine_ease_out #

fn sine_ease_out(p f64) f64

sine_ease_out decelerates using a sine formula

type EasingFn #

type EasingFn = fn (x f64) f64