mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 06:30:19 +00:00
8a64b7621d
# Objective - Currently we have the `ColorRange` trait to interpolate linearly between two colors - It would be cool to have: 1. linear interpolation between n colors where `n >= 1` 2. other kinds of interpolation ## Solution 1. Implement `ColorGradient` which takes `n >= 1` colors and linearly interpolates between consecutive pairs of them 2. Implement `Curve` intergration for this `ColorGradient` which yields a curve struct. After that we can apply all of the cool curve adaptors like `.reparametrize()` and `.map()` to the gradient ## Testing - Added doc tests - Added tests ## Showcase ```rust // let gradient = ColorGradient::new(vec![]).unwrap(); // panic! 💥 let gradient = ColorGradient::new([basic::RED, basic::LIME, basic::BLUE]).expect("non-empty"); let curve = gradient.to_curve(); let brighter_curve = curve.map(|c| c.mix(&basic::WHITE, 0.5)); ``` --- Kind of related to https://github.com/bevyengine/bevy/pull/14971#discussion_r1736337631 --------- Co-authored-by: Zachary Harrold <zac@harrold.com.au> Co-authored-by: Matty <weatherleymatthew@gmail.com> |
||
---|---|---|
.. | ||
crates/gen_tests | ||
docs | ||
src | ||
Cargo.toml | ||
README.md |