pub struct ColorGenerator { /* private fields */ }Expand description
Automatic color generator for creating visually distinct label colors.
ColorGenerator produces a sequence of pseudo-random colors that are perceptually distinct and readable. It’s useful for assigning colors to multiple labels automatically.
§Examples
use musubi::{Report, ColorGenerator, Level};
let mut cg = ColorGenerator::new();
Report::new()
// ...
.with_label(0..3)
.with_color(&cg.next_color()) // First color
.with_label(4..5)
.with_color(&cg.next_color()) // Second color (different)
// ...Implementations§
Source§impl ColorGenerator
impl ColorGenerator
Sourcepub fn new_with_brightness(brightness: f32) -> Self
pub fn new_with_brightness(brightness: f32) -> Self
Create a new color generator with the specified brightness.
Sourcepub fn next_color(&mut self) -> GenColor
pub fn next_color(&mut self) -> GenColor
Generate the next color in the sequence.
Each call returns a different color code that is visually distinct from previous colors. The sequence is deterministic based on the initial state.
§Examples
use musubi::ColorGenerator;
let mut cg = ColorGenerator::new();
let color1 = cg.next_color();
let color2 = cg.next_color(); // Different from color1
let color3 = cg.next_color(); // Different from color1 and color2Trait Implementations§
Auto Trait Implementations§
impl Freeze for ColorGenerator
impl RefUnwindSafe for ColorGenerator
impl Send for ColorGenerator
impl Sync for ColorGenerator
impl Unpin for ColorGenerator
impl UnwindSafe for ColorGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more