mirror of
https://codeberg.org/icewind/contrast.git
synced 2026-06-03 09:54:19 +02:00
Calculate contrast between two colors
- Rust 88.3%
- Nix 11.7%
| src | ||
| .envrc | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE-APACHE | ||
| LICENSE-MIT | ||
| README.md | ||
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
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
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.