color
color copied to clipboard
Using Contrast Methods
Firstly, thanks for this Gem, it has helped a lot with a current project!
I may not have a full grasp of how Gems are packaged or something, so I have a few questions.
Is there a reason that the methods in lib/color/rgb/contrast.rb
aren't available in the current Gem? Is it because it is in a subdirectory to where the class Color::RGB
is defined? Or that the file doesn't have the include Color
line?
When I try to use the method like follows, I get an undefined method error for contrast
.
irb(main):006:0> Color::RGB.by_css('ffffff').contrast(Color::RGB.by_css('000000'))
NoMethodError: undefined method `contrast' for RGB [#ffffff]:Color::RGB
from (irb):6
from /home/jacob/.rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
I forked the repo and just copied the methods from contrast.rb
into rgb.rb
, added my git repo to my Gemfile in a rails project and the methods seem to work excellently. See this commit in my fork. I use the contrast method and it works great.
Just wondering if maybe I'm missing something on how it is supposed to be used, or if it isn't ready for production due to a lack of tests or something. For now, I'll use my fork, and again, thank you to everybody who has helped with this Gem!
If I remember correctly, this was intentional—the methods were considered experimental pending further reflection, so that if you need the contrast methods, you just require 'color/rgb/contrast'
.
It's 2021, and this is still experimental. : sad panda :
Unfortunately, this gem is essentially unmaintained. I no longer have need for the colour utilities, and no one has to date expressed interest in taking over the development of the code.