{"id":26050991,"url":"https://github.com/spenserblack/relative-luminance-rs","last_synced_at":"2026-03-09T14:33:22.162Z","repository":{"id":271801667,"uuid":"914037217","full_name":"spenserblack/relative-luminance-rs","owner":"spenserblack","description":"Get the relative luminance of a color","archived":false,"fork":false,"pushed_at":"2025-05-14T13:43:16.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T13:48:25.884Z","etag":null,"topics":["color","contrast","luminance","luminosity","theme"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spenserblack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-08T20:34:00.000Z","updated_at":"2025-05-14T13:43:20.000Z","dependencies_parsed_at":"2025-01-10T01:19:33.857Z","dependency_job_id":"40d8b37d-c9c8-4220-ac7d-52cc9e8b2afc","html_url":"https://github.com/spenserblack/relative-luminance-rs","commit_stats":null,"previous_names":["spenserblack/relative-luminance-rs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/spenserblack/relative-luminance-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spenserblack%2Frelative-luminance-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spenserblack%2Frelative-luminance-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spenserblack%2Frelative-luminance-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spenserblack%2Frelative-luminance-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spenserblack","download_url":"https://codeload.github.com/spenserblack/relative-luminance-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spenserblack%2Frelative-luminance-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30299105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T13:46:43.843Z","status":"ssl_error","status_checked_at":"2026-03-09T13:46:42.821Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["color","contrast","luminance","luminosity","theme"],"created_at":"2025-03-08T03:28:50.826Z","updated_at":"2026-03-09T14:33:22.138Z","avatar_url":"https://github.com/spenserblack.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# relative-luminance\n\n[![Crates.io Version](https://img.shields.io/crates/v/relative-luminance)](https://crates.io/crates/relative-luminance)\n[![CI](https://github.com/spenserblack/relative-luminance-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/spenserblack/relative-luminance-rs/actions/workflows/ci.yml)\n\nThis is a small crate that provides utilities to handle\n[relative luminance][relative-luminance]. In short, among RGB color channels, green\nrepresents the majority of light perceived by the typical human eye, then red, then\nblue. This can explain why white text may be hard to read on a green (`#00FF00`)\nbackground, yet black text can be hard to read on a blue (`#0000FF`) background.\n\n| background | foreground | readability |\n| :--------: | :--------: | :---------: |\n| `#00FF00` | `#FFFFFF` | hard to read |\n| `#00FF00` | `#000000` | readable |\n| `#0000FF` | `#FFFFFF` | readable |\n| `#0000FF` | `#000000` | hard to read |\n\nRun `cargo run --example contrast` to see an example of how this looks.\n\n## Example usage\n\n```rust\nuse relative_luminance::*;\n\n// Choose a foreground color that contrasts with the background color\nlet fg_color = if bg_color.relative_luminance() \u003e 0.5 {\n    dark_color\n} else {\n    light_color\n};\n\nprintln!(\"{}\", \"Hello, World!\".color(fg_color).on_color(bg_color));\n```\n\n[relative-luminance]: https://en.wikipedia.org/wiki/Relative_luminance\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspenserblack%2Frelative-luminance-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspenserblack%2Frelative-luminance-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspenserblack%2Frelative-luminance-rs/lists"}