#color #calculate #rgb #wcag #rgb8

contrast

Calculate contrast between two colors

1 unstable release

0.1.0 Sep 7, 2019

#54 in #colors

Download history 518/week @ 2024-07-22 268/week @ 2024-07-29 353/week @ 2024-08-05 288/week @ 2024-08-12 453/week @ 2024-08-19 263/week @ 2024-08-26 497/week @ 2024-09-02 351/week @ 2024-09-09 293/week @ 2024-09-16 281/week @ 2024-09-23 397/week @ 2024-09-30 271/week @ 2024-10-07 409/week @ 2024-10-14 353/week @ 2024-10-21 309/week @ 2024-10-28 322/week @ 2024-11-04

1,396 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