#color #calculate #rgb #wcag #rgb8

contrast

Calculate contrast between two colors

1 unstable release

0.1.0 Sep 7, 2019

#524 in Images

Download history 467/week @ 2023-12-02 201/week @ 2023-12-09 611/week @ 2023-12-16 516/week @ 2023-12-23 380/week @ 2023-12-30 423/week @ 2024-01-06 616/week @ 2024-01-13 628/week @ 2024-01-20 371/week @ 2024-01-27 410/week @ 2024-02-03 365/week @ 2024-02-10 439/week @ 2024-02-17 937/week @ 2024-02-24 813/week @ 2024-03-02 516/week @ 2024-03-09 711/week @ 2024-03-16

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

~235KB