pub fn with_color_func(fn_: ColorFunc) -> OptionExpand description
WithColorFunc sets a function that can be used to dynamically fill the progress bar based on the current percentage. total is the total filled percentage, and current is the current percentage that is actively being filled with a color. When specified, this overrides any other defined colors and scaling.
Example: A progress bar that changes color based on the total completed percentage:
progress::with_color_func(Box::new(|total, _current| {
if total <= 0.3 {
return Color::parse("#FF0000");
}
if total <= 0.7 {
return Color::parse("#00FF00");
}
Color::parse("#0000FF")
}));