INNER CODE UNIT · Rust
to_cmyk
sharkdp/pastel · src/lib.rs:276
pub fn to_cmyk(&self) -> CMYK {
CMYK::from(self)
}
/// Format the color as a CMYK-representation string (`cmyk(0, 50, 100, 100)`).
pub fn to_cmyk_string(&self, format: Format) -> String {
let cmyk = CMYK::from(self);
format!(
"cmyk({c},{space}{m},{space}{y},{space}{k})",
c = (cmyk.c * 100.0).round(),
m = (cmyk.m * 100.0).round(),
y = (cmyk.y * 100.0).round(),
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