Function smoothstep
pub fn smoothstep(from: f64, to: f64, x: f64) -> f64Expand description
Returns a smooth cubic Hermite interpolation between 0 and 1.
For positive ranges (when from <= to) the return value is 0 when x <= from, and 1 when x >= to. If x lies between from and to, the return value follows an S-shaped curve that smoothly transitions from 0 to 1.
For negative ranges (when from > to) the function is mirrored and returns 1 when x <= to and 0 when x >= from.
This S-shaped curve is the cubic Hermite interpolator, given by f(y) = 3*y^2 - 2*y^3 where y = (x-from) / (to-from).
smoothstep(0, 2, -5.0) # Returns 0.0
smoothstep(0, 2, 0.5) # Returns 0.15625
smoothstep(0, 2, 1.0) # Returns 0.5
smoothstep(0, 2, 2.0) # Returns 1.0Compared to [method ease] with a curve value of -1.6521, [method smoothstep] returns the smoothest possible curve with no sudden changes in the derivative. If you need to perform more advanced transitions, use Tween or AnimationPlayer.
Comparison between smoothstep() and ease(x, -1.6521) return values
Smoothstep() return values with positive, zero, and negative ranges