https://github.com/myndex/max-contrast
Send it the background color, returns black or white whichever is maximum Lc value
https://github.com/myndex/max-contrast
apca color contrast contrast-enhancement contrast-ratio css wcag web-colors
Last synced: 14 days ago
JSON representation
Send it the background color, returns black or white whichever is maximum Lc value
- Host: GitHub
- URL: https://github.com/myndex/max-contrast
- Owner: Myndex
- License: gpl-3.0
- Created: 2023-08-29T11:50:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-01T16:12:39.000Z (over 1 year ago)
- Last Synced: 2025-03-31T09:41:15.875Z (about 2 months ago)
- Topics: apca, color, contrast, contrast-enhancement, contrast-ratio, css, wcag, web-colors
- Language: JavaScript
- Homepage:
- Size: 6.9 MB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# maxContrast()
Send it the background color, it returns a black or white text color, whichever is maximum APCA Lc value```JS
// Version in maxContrastArray.js
let color = maxContrast([0xce,0x96,0x99])
console.log(color); // [0,0,0]```
```JS// Version in maxContrastString.js
let color = maxContrast(119,127,206)
console.log(color); // 'white'```
This is part of the [APCA contrast project](https://github.com/Myndex/SAPC-APCA).
## Files
- `/src/maxContrastArray.js` send an RGB array, it returns an RGB array, suitable for use with [ColorParsley](https://github.com/Myndex/colorparsley)- `/src/maxContrastString.js` send R G and B ints, it returns a color string.
### Related Resources
- [Fancy Font Flipping](https://github.com/Myndex/fancyfontflipping) experimental demonstrator showing the ideas behind this.
- [APCA Linktree](https://linktr.ee/Myndex) Curated quick-start documentation for APCA
- [APCA Documentation Repo](https://github.com/Myndex/SAPC-APCA) Main APCA docs
- [APCA Readability Criterion](https://readtech.org/ARC/) public working draft
- [apca-w3](https://github.com/Myndex/apca-w3) public APCA for W3 and WCAG 3
- [ColorParsley](https://github.com/Myndex/colorparsley) lightweight micro-library for parsing colorsLicense is modified GNU 3.
![]()
Copyright © 2023 by Andrew Somers. All Rights Reserved.