INNER CODE UNIT · Rust

to_hsva

sharkdp/pastel · src/lib.rs:208

    pub fn to_hsva(&self) -> HSVA {
        HSVA::from(self)
    }

    /// Format the color as a HSV-representation string (`hsva(123, 50.3%, 80.1%, 0.4)`). If the
    /// alpha channel is `1.0`, the simplified `hsv()` format will be used instead.
    pub fn to_hsv_string(&self, format: Format) -> String {
        let hsv = HSVA::from(self);
        let space = if format == Format::Spaces { " " } else { "" };
        let (a_prefix, a) = if hsv.alpha == 1.0 {
            ("", "".to_string())
        } else {
            (
                "a",
                format!(
                    ",{space}{alpha}",
                    alpha = MaxPrecision::wrap(3, hsv.alpha),
                    space = space

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…