Calculate contrast between two colors
  • Rust 88.3%
  • Nix 11.7%
Find a file
2025-05-31 14:10:53 +02:00
src readme 2019-09-07 16:17:46 +02:00
.envrc add dev flake 2025-05-31 14:10:00 +02:00
.gitignore add dev flake 2025-05-31 14:10:00 +02:00
Cargo.lock add dev flake 2025-05-31 14:10:00 +02:00
Cargo.toml update repo link 2025-05-31 14:10:53 +02:00
flake.lock add dev flake 2025-05-31 14:10:00 +02:00
flake.nix add dev flake 2025-05-31 14:10:00 +02:00
LICENSE-APACHE add licence stuff 2019-09-07 16:26:56 +02:00
LICENSE-MIT add licence stuff 2019-09-07 16:26:56 +02:00
README.md add dev flake 2025-05-31 14:10:00 +02:00

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.