Created
October 31, 2016 17:40
-
-
Save eymiha/d293347c6516512f1baeebdecbf53f2d to your computer and use it in GitHub Desktop.
Given a color with a target perceived brightness and another color with a target hue and saturation, it builds the target color
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
| require "WebColor" | |
| def equibright hex_s, hex_d | |
| color_s = WebColor.new hex_s | |
| color_d = WebColor.new hex_d | |
| h = color_d.hue | |
| s = color_d.saturation | |
| p = color_s.perceived_brightness | |
| puts WebColor.fromHSP(h,s,p).hex | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment