bevy/crates
Robert Walter 59db6f9cca
add curve utilities to create curves interpolating/easing between two values (#14788)
# Objective

Citing @mweatherley 

> There is a lot of shortfall for simple cases— e.g., we should have
library functions for making a curve connecting two points, eased
versions of that, and so on.

## Solution

This PR implements

- a simple `Easing` trait which is implemented for all `impl Curve<f32>`
types. We can't really guarantee that these curves have unit interval
domain, which some people would probably expect, but it is documented
that this isn't the case for these types and we redirect to
`EasingCurve` which is used for that purpose
- an `EasingCurve` struct, which is used to interpolate between two
values `start` and `end` using a `impl Easing` curve where the curve
will be guaranteed to be reparametrized
- a `LinearCurve` which linearly interpolates between two values `start`
and `end`
- a `CubicBezierCurve` which interpolates between `start` and `end`
values using a `CubicSegment`
- a `StepCurve` which interpolates between `start` and `end` with an
step-function with `n` steps
- an `ElasticCurve` which interpolates between `start` and `end` with
spring like behavior where the elasticity of the spring is configurable
- some `FunctionCurve` easing curves for different popular functions
including: `quadratic_ease_in`, `quadratic_ease_out`, `smoothstep`,
`identity`

## Testing

- there are a few new tests for all of these in the main module

---------

Co-authored-by: eckz <567737+eckz@users.noreply.github.com>
Co-authored-by: Miles Silberling-Cook <NthTensor@users.noreply.github.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Matty <weatherleymatthew@gmail.com>
2024-10-02 14:29:05 +00:00
..
bevy_a11y
bevy_animation
bevy_app
bevy_asset
bevy_audio
bevy_color
bevy_core
bevy_core_pipeline
bevy_derive
bevy_dev_tools
bevy_diagnostic
bevy_dylib
bevy_ecs
bevy_encase_derive
bevy_gilrs
bevy_gizmos
bevy_gltf
bevy_hierarchy
bevy_input
bevy_internal
bevy_log
bevy_macro_utils
bevy_math
bevy_mikktspace
bevy_pbr
bevy_picking
bevy_ptr
bevy_reflect
bevy_remote
bevy_render
bevy_scene
bevy_sprite
bevy_state
bevy_tasks
bevy_text
bevy_time
bevy_transform
bevy_ui
bevy_utils
bevy_window
bevy_winit