-
-
Notifications
You must be signed in to change notification settings - Fork 229
Description
Problem
Currently, pygame.math.lerp(a, b, t) only performs linear interpolation. While useful, linear movement often feels "robotic" or "stiff" in game design.
To achieve smooth animations (like a UI panel sliding in or a camera smoothing effect), developers currently have to:
Manually apply an easing formula to the t value before passing it to lerp.
Find or write their own easing library.Proposed SolutionEnhance pygame.math.lerp to accept an optional easing parameter. This could be a string identifier for built-in presets or a callable function.
Proposed Syntax:
pygame.math.lerp(start, end, t, easing="ease_out_cubic")
Using a custom callable
pygame.math.lerp(start, end, t, easing=my_custom_ease_func)
Feature Details Built-in Presets: Include common formulas like quad, cubic, expo, and sine.
Mathematical Formula: The easing function would transform the t (0.0 to 1.0) value before the linear calculation is applied:$t_{eased} = f(t)$$result = a + (b - a) \times t_{eased}$Performance: These could be implemented in C within the pygame.math module for high-performance animation updates.
Documentation ImprovementsAdding this feature would require a new section in the docs explaining: The difference between linear and eased interpolation.
A list of all supported easing strings.
Visual examples or graphs of the easing curves to help developers choose the right one.
Sources for easing functions can be found here