ColorAdjuster
A tiny module mixin for adding color adjusting methods to a class that responds to color
.
Installation
Add this line to your application's Gemfile:
gem 'ColorAdjuster'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ColorAdjuster
Usage
Drop this module in a model or class that responds to color
and returns a hex string:
class Status
include ColorAdjuster
def color
"#ff0000"
end
end
Now you can ask it to darken or lighten the color:
status = Status.new
status.darken_color # => "#660000"
status.lighten_color # => "#ff4d4d"
status.contrasting_color # => "#ff9999"
Thanks to this blog post for the code.
Contributing
- Fork it ( https://github.com/[my-github-username]/ColorAdjuster/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request