#color #calculate #rgb #wcag #rgb8

contrast

Calculate contrast between two colors

1 unstable release

0.1.0 Sep 7, 2019

#71 in #calculate

Download history 471/week @ 2024-10-01 211/week @ 2024-10-08 413/week @ 2024-10-15 337/week @ 2024-10-22 282/week @ 2024-10-29 304/week @ 2024-11-05 561/week @ 2024-11-12 465/week @ 2024-11-19 443/week @ 2024-11-26 269/week @ 2024-12-03 357/week @ 2024-12-10 360/week @ 2024-12-17 242/week @ 2024-12-24 344/week @ 2024-12-31 466/week @ 2025-01-07 304/week @ 2025-01-14

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