core/math/ease
ease
Types
3Ease
Ease :: enum int {
Linear = 0,
Quadratic_In = 1,
Quadratic_Out = 2,
Quadratic_In_Out = 3,
Cubic_In = 4,
Cubic_Out = 5,
Cubic_In_Out = 6,
Quartic_In = 7,
Quartic_Out = 8,
Quartic_In_Out = 9,
Quintic_In = 10,
Quintic_Out = 11,
Quintic_In_Out = 12,
Sine_In = 13,
Sine_Out = 14,
Sine_In_Out = 15,
Circular_In = 16,
Circular_Out = 17,
Circular_In_Out = 18,
Exponential_In = 19,
Exponential_Out = 20,
Exponential_In_Out = 21,
Elastic_In = 22,
Elastic_Out = 23,
Elastic_In_Out = 24,
Back_In = 25,
Back_Out = 26,
Back_In_Out = 27,
Bounce_In = 28,
Bounce_Out = 29,
Bounce_In_Out = 30,
}Sourceadditional enum variant
Flux_Map
Flux_Map :: struct {}SourceFlux_Tween
Flux_Tween :: struct {}SourceProcedures
61back_in
back_in :: proc(p: T) -> (T)SourceModeled after the overshooting cubic y = x^3-xsin(xpi)
back_in_out
back_in_out :: proc(p: T) -> (T)SourceModeled after the piecewise overshooting cubic function: y = (1/2)((2x)^3-(2x)sin(2xpi)) ; [0, 0.5) y = (1/2)(1-((1-x)^3-(1-x)sin((1-x)*pi))+1) ; [0.5, 1]
back_out
back_out :: proc(p: T) -> (T)SourceModeled after overshooting cubic y = 1-((1-x)^3-(1-x)sin((1-x)pi))
bounce_in
bounce_in :: proc(p: T) -> (T)Sourcebounce_in_out
bounce_in_out :: proc(p: T) -> (T)Sourcebounce_out
bounce_out :: proc(p: T) -> (T)Sourcecircular_in
circular_in :: proc(p: T) -> (T)SourceModeled after shifted quadrant IV of unit circle
circular_in_inverse
circular_in_inverse :: proc(p: T) -> (T)SourceInverse of circular_in x = sqrt(2y - y²)
circular_in_out
circular_in_out :: proc(p: T) -> (T)SourceModeled after the piecewise circular function y = (1/2)(1 - sqrt(1 - 4x^2)) ; [0, 0.5) y = (1/2)(sqrt(-(2x - 3)*(2x - 1)) + 1) ; [0.5, 1]
circular_in_out_inverse
circular_in_out_inverse :: proc(p: T) -> (T)SourceInverse of circular_in_out x = sqrt(1 - (1-2y)²) / 2 ; [0, 0.5) x = 1 - sqrt(1 - (2y-1)²) / 2 ; [0.5, 1]
circular_out
circular_out :: proc(p: T) -> (T)SourceModeled after shifted quadrant II of unit circle
circular_out_inverse
circular_out_inverse :: proc(p: T) -> (T)SourceInverse of circular_out x = 1 - sqrt(1 - y²)
cubic_in
cubic_in :: proc(p: T) -> (T)SourceModeled after the cubic y = x^3
cubic_in_inverse
cubic_in_inverse :: proc(p: T) -> (T)SourceInverse of cubic_in x = y^(1/3)
cubic_in_out
cubic_in_out :: proc(p: T) -> (T)SourceModeled after the piecewise cubic y = (1/2)((2x)^3) ; [0, 0.5) y = (1/2)((2x-2)^3 + 2) ; [0.5, 1]
cubic_in_out_inverse
cubic_in_out_inverse :: proc(p: T) -> (T)SourceInverse of cubic_in_out x = (y/4)^(1/3) ; [0, 0.5) x = ((y-1)*2)^(1/3)/2 + 1 ; [0.5, 1]
cubic_out
cubic_out :: proc(p: T) -> (T)SourceModeled after the cubic y = (x - 1)^3 + 1
cubic_out_inverse
cubic_out_inverse :: proc(p: T) -> (T)SourceInverse of cubic_out x = (y - 1)^(1/3) + 1
ease
ease :: proc(type: Ease, p: T) -> (T)Sourceease_inverse
ease_inverse :: proc(type: Ease, p: T) -> (T)SourceAdditional enum variant
elastic_in
elastic_in :: proc(p: T) -> (T)SourceModeled after the damped sine wave y = sin(13pi/2x)pow(2, 10 * (x - 1))
elastic_in_out
elastic_in_out :: proc(p: T) -> (T)SourceModeled after the piecewise exponentially-damped sine wave: y = (1/2)sin(13pi/2(2x))pow(2, 10 ((2x) - 1)) ; [0,0.5) y = (1/2)(sin(-13pi/2((2x-1)+1))pow(2,-10(2x-1)) + 2) ; [0.5, 1]
elastic_out
elastic_out :: proc(p: T) -> (T)SourceModeled after the damped sine wave y = sin(-13pi/2(x + 1))pow(2, -10x) + 1
exponential_in
exponential_in :: proc(p: T) -> (T)SourceModeled after the exponential function y = 2^(10(x - 1))
exponential_in_inverse
exponential_in_inverse :: proc(p: T) -> (T)SourceInverse of exponential_in x = log₂(y) / 10 + 1
exponential_in_out
exponential_in_out :: proc(p: T) -> (T)SourceModeled after the piecewise exponential y = (1/2)2^(10(2x - 1)) ; [0,0.5) y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1]
exponential_in_out_inverse
exponential_in_out_inverse :: proc(p: T) -> (T)SourceInverse of exponential_in_out x = (log₂(2y) + 10) / 20 ; [0, 0.5) x = (10 - log₂(2(1-y))) / 20 ; [0.5, 1]
exponential_out
exponential_out :: proc(p: T) -> (T)SourceModeled after the exponential function y = -2^(-10x) + 1
exponential_out_inverse
exponential_out_inverse :: proc(p: T) -> (T)SourceInverse of exponential_out x = -log₂(1 - y) / 10
flux_clear
flux_clear :: proc(flux: ^Flux_Map($T))Sourceclear map content, stops all animations
flux_destroy
flux_destroy :: proc(flux: Flux_Map($T), allocator: mem.Allocator = context.allocator, loc = #caller_location)Sourcedelete map content
flux_init
flux_init :: proc(T: typeid, value_capacity: untyped integer = 8, allocator: mem.Allocator = context.allocator, loc = #caller_location) -> (Flux_Map($T=typeid))Sourceinit flux map to a float type and a wanted cap
flux_stop
flux_stop :: proc(flux: ^Flux_Map($T), key: ^T) -> (bool)Sourcestop a specific key inside the map returns true when it successfully removed the key
flux_to
flux_to :: proc(
flux: ^Flux_Map($T),
value: ^T,
goal: T,
type: Ease,
duration: time.Duration,
delay: f64,
) -> (tween: ^Flux_Tween(T))Sourceappend / overwrite existing tween value to parameters rest is initialized in flux_tween_init, inside update return value can be used to set callbacks
flux_tween_init
flux_tween_init :: proc(tween: ^Flux_Tween($T), duration: time.Duration)Sourceinit internal properties
flux_tween_time_left
flux_tween_time_left :: proc(flux: Flux_Map($T), key: ^T) -> (f64)Sourcereturns the amount of time left for the tween animation, if the key exists in the map returns 0 if the tween doesn't exist on the map
flux_update
flux_update :: proc(flux: ^Flux_Map($T), dt: f64)Sourceupdate all tweens, wait for their delay if one exists calls callbacks in all stages, when they're filled deletes tween from the map after completion
quadratic_in
quadratic_in :: proc(p: T) -> (T)Sourceconverted to odin from https://github.com/warrenm/AHEasing with additional enum based call Modeled after the parabola y = x^2
quadratic_in_inverse
quadratic_in_inverse :: proc(p: T) -> (T)SourceInverse of quadratic_in x = sqrt(y)
quadratic_in_out
quadratic_in_out :: proc(p: T) -> (T)SourceModeled after the piecewise quadratic y = (1/2)((2x)^2) ; [0, 0.5) y = -(1/2)((2x-1)*(2x-3) - 1) ; [0.5, 1]
quadratic_in_out_inverse
quadratic_in_out_inverse :: proc(p: T) -> (T)SourceInverse of quadratic_in_out x = sqrt(y/2) ; [0, 0.5) x = 1 - sqrt((1-y)/2) ; [0.5, 1]
quadratic_out
quadratic_out :: proc(p: T) -> (T)SourceModeled after the parabola y = -x^2 + 2x
quadratic_out_inverse
quadratic_out_inverse :: proc(p: T) -> (T)SourceInverse of quadratic_out x = 1 - sqrt(1 - y)
quartic_in
quartic_in :: proc(p: T) -> (T)SourceModeled after the quartic x^4
quartic_in_inverse
quartic_in_inverse :: proc(p: T) -> (T)SourceInverse of quartic_in x = y^(1/4)
quartic_in_out
quartic_in_out :: proc(p: T) -> (T)SourceModeled after the piecewise quartic y = (1/2)((2x)^4) ; [0, 0.5) y = -(1/2)((2x-2)^4 - 2) ; [0.5, 1]
quartic_in_out_inverse
quartic_in_out_inverse :: proc(p: T) -> (T)SourceInverse of quartic_in_out x = (y/8)^(1/4) ; [0, 0.5) x = 1 - ((1-y)/8)^(1/4) ; [0.5, 1]
quartic_out
quartic_out :: proc(p: T) -> (T)SourceModeled after the quartic y = 1 - (x - 1)^4
quartic_out_inverse
quartic_out_inverse :: proc(p: T) -> (T)SourceInverse of quartic_out x = 1 - (1 - y)^(1/4)
quintic_in
quintic_in :: proc(p: T) -> (T)SourceModeled after the quintic y = x^5
quintic_in_inverse
quintic_in_inverse :: proc(p: T) -> (T)SourceInverse of quintic_in x = y^(1/5)
quintic_in_out
quintic_in_out :: proc(p: T) -> (T)SourceModeled after the piecewise quintic y = (1/2)((2x)^5) ; [0, 0.5) y = (1/2)((2x-2)^5 + 2) ; [0.5, 1]
quintic_in_out_inverse
quintic_in_out_inverse :: proc(p: T) -> (T)SourceInverse of quintic_in_out x = (y/16)^(1/5) ; [0, 0.5) x = ((y-1)*2)^(1/5)/2 + 1 ; [0.5, 1]
quintic_out
quintic_out :: proc(p: T) -> (T)SourceModeled after the quintic y = (x - 1)^5 + 1
quintic_out_inverse
quintic_out_inverse :: proc(p: T) -> (T)SourceInverse of quintic_out x = (y - 1)^(1/5) + 1
sine_in
sine_in :: proc(p: T) -> (T)SourceModeled after quarter-cycle of sine wave
sine_in_inverse
sine_in_inverse :: proc(p: T) -> (T)SourceInverse of sine_in x = asin(y - 1) * 2/π + 1
sine_in_out
sine_in_out :: proc(p: T) -> (T)SourceModeled after half sine wave
sine_in_out_inverse
sine_in_out_inverse :: proc(p: T) -> (T)SourceInverse of sine_in_out x = acos(1 - 2y) / π
sine_out
sine_out :: proc(p: T) -> (T)SourceModeled after quarter-cycle of sine wave (different phase)
sine_out_inverse
sine_out_inverse :: proc(p: T) -> (T)SourceInverse of sine_out x = asin(y) * 2/π