#color #calculate #rgb #wcag #rgb8

contrast

Calculate contrast between two colors

1 unstable release

0.1.0 Sep 7, 2019

#72 in #calculate

Download history 372/week @ 2024-10-04 371/week @ 2024-10-11 365/week @ 2024-10-18 277/week @ 2024-10-25 316/week @ 2024-11-01 313/week @ 2024-11-08 700/week @ 2024-11-15 454/week @ 2024-11-22 298/week @ 2024-11-29 236/week @ 2024-12-06 409/week @ 2024-12-13 261/week @ 2024-12-20 311/week @ 2024-12-27 488/week @ 2025-01-03 237/week @ 2025-01-10 285/week @ 2025-01-17

1,352 downloads per month
Used in 2 crates

MIT/Apache

7KB
56 lines

Contrast

Calculate contrast between two colors as specified by WCAG 2

Usage

use contrast::contrast;
use rgb::RGB8;
///
fn main() {
    let contrast: f32 = contrast(RGB8::from([255, 255, 255]), RGB8::from([255, 255, 0]));
    assert_eq!(contrast, 1.0738392);
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~290KB