Created
April 24, 2024 14:05
-
-
Save atebit/08a9d518516d444b86a7feaa4e8dd718 to your computer and use it in GitHub Desktop.
Javascript Color Contrast Algo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exportColor = (flags) => { | |
| if (!(flags & leaveValue) && valueElement) { | |
| // Implement logic for valueElement | |
| } | |
| let value = this.toString(); | |
| if (this.caps) value = value.toUpperCase(); | |
| if (this.hash) value = '#' + value; | |
| valueElement.value = value; | |
| if (!(flags & leaveStyle) && styleElement) { | |
| styleElement.style.backgroundImage = "none"; | |
| styleElement.style.backgroundColor = '#' + this.toString(); | |
| styleElement.style.color = (0.213 * this.rgb[0] + 0.715 * this.rgb[1] + 0.072 * this.rgb[2] < 0.5) ? '#FFF' : '#000'; | |
| } | |
| if (!(flags & leavePad) && isPickerOwner()) redrawPad(); | |
| if (!(flags & leaveSld) && isPickerOwner()) redrawSld(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment