mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
043041f3aa
# Objective - Fixes #12170 ## Solution - Moved the existing `color_from_entity` internals into `Hsla::sequence_dispersed` which generates a randomly distributed but deterministic color sequence based. - Replicated the method for `Lcha` and `Oklcha` as well. ## Examples ### Getting a few colours for a quick palette ```rust let palette = Hsla::sequence_dispersed().take(5).collect::<Vec<_>>(); /*[ Hsla::hsl(0.0, 1., 0.5), Hsla::hsl(222.49225, 1., 0.5), Hsla::hsl(84.984474, 1., 0.5), Hsla::hsl(307.4767, 1., 0.5), Hsla::hsl(169.96895, 1., 0.5), ]*/ ``` ### Getting a colour from an `Entity` ```rust let color = Oklcha::sequence_dispersed().nth(entity.index() as u32).unwrap(); ``` ## Notes This was previously a private function exclusively for `Entity` types. I've decided it should instead be public and operate on a `u32` directly, since this function may have broader uses for debugging purposes. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> |
||
---|---|---|
.. | ||
crates/gen_tests | ||
docs | ||
src | ||
Cargo.toml |