Created
April 24, 2024 14:00
-
-
Save atebit/843323862b8325430dae324d34b7aeec to your computer and use it in GitHub Desktop.
Ruby 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
| def export_color(flags) | |
| unless flags & leave_value != 0 && value_element.nil? | |
| # Implement your logic for handling value_element | |
| end | |
| value = to_s | |
| value = value.upcase if caps | |
| value = "##{value}" if hash | |
| value_element.value = value unless value_element.nil? | |
| unless flags & leave_style != 0 && style_element.nil? | |
| style_element.style.background_image = "none" | |
| style_element.style.background_color = "##{to_s}" | |
| luminance = 0.213 * rgb[0] + 0.715 * rgb[1] + 0.072 * rgb[2] | |
| text_color = luminance < 0.5 ? '#FFF' : '#000' | |
| style_element.style.color = text_color | |
| end | |
| redraw_pad unless flags & leave_pad != 0 && is_picker_owner | |
| redraw_sld unless flags & leave_sld != 0 && is_picker_owner | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment