INNER CODE UNIT · Rust

to_cmyk_string

sharkdp/pastel · src/lib.rs:281

    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
    /// 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 {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…