Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rmorlang/52732 to your computer and use it in GitHub Desktop.
Save rmorlang/52732 to your computer and use it in GitHub Desktop.
# The bug below has been fixed in color 1.4 which is
# the successor to color-tools 1.3.0
#
# There's a bug in color-tools when converting HSL to RGB for desaturated
# colors. It doesn't multiple the lightness value by 255, so every resulting
# set of RGB values ends up being (1,1,1). This monkeypatch fixes it.
class Color::HSL
def to_rgb_with_saturation_bugfix(ignored = nil)
return Color::RGB.new(*([@l * 0xff] * 3)) if @s <= 1e-5
to_rgb_without_saturation_bugfix(ignored)
end
alias :to_rgb_without_saturation_bugfix :to_rgb
alias :to_rgb :to_rgb_with_saturation_bugfix
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment