Skip to content

Instantly share code, notes, and snippets.

@eymiha
Created October 31, 2016 17:40
Show Gist options
  • Select an option

  • Save eymiha/d293347c6516512f1baeebdecbf53f2d to your computer and use it in GitHub Desktop.

Select an option

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
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