#color #calculate #rgb #wcag #rgb8

contrast

Calculate contrast between two colors

1 unstable release

0.1.0 Sep 7, 2019

#74 in #calculate

Download history 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 236/week @ 2025-01-10 385/week @ 2025-01-17 268/week @ 2025-01-24 310/week @ 2025-01-31 570/week @ 2025-02-07 664/week @ 2025-02-14 1069/week @ 2025-02-21 1043/week @ 2025-02-28

3,442 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