INNER CODE UNIT · Rust

v

sharkdp/pastel · src/lib.rs:235

            v = 100.0 * hsv.v,
            a = a,
        )
    }

    /// Convert a `Color` to its red, green, blue and alpha values. The RGB values are integers in
    /// the range from 0 to 255. The alpha channel is a number between 0.0 and 1.0.
    pub fn to_rgba(&self) -> RGBA<u8> {
        RGBA::<u8>::from(self)
    }

    /// Format the color as a RGB-representation string (`rgba(255, 127, 0, 0.5)`). If the alpha channel
    /// is `1.0`, the simplified `rgb()` format will be used instead.
    pub fn to_rgb_string(&self, format: Format) -> String {
        let rgba = RGBA::<u8>::from(self);
        let space = if format == Format::Spaces { " " } else { "" };
        let (a_prefix, a) = if self.alpha == 1.0 {
            ("", "".to_string())

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…