INNER CODE UNIT · Rust
k
sharkdp/pastel · src/lib.rs:288
k = (cmyk.k * 100.0).round(),
space = if format == Format::Spaces { " " } else { "" }
)
}
/// Format the color as a floating point RGB-representation string (`rgb(1.0, 0.5, 0)`). If the alpha channel
/// is `1.0`, the simplified `rgb()` format will be used instead.
pub fn to_rgb_float_string(&self, format: Format) -> String {
let rgba = RGBA::<f64>::from(self);
let space = if format == Format::Spaces { " " } else { "" };
let (a_prefix, a) = if self.alpha == 1.0 {
("", "".to_string())
} else {
(
"a",
format!(
",{space}{alpha}",
alpha = MaxPrecision::wrap(3, rgba.alpha),