Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/plashchynski/rgb
A simple Ruby library built to handle easy conversion and manipulation of colors.
https://github.com/plashchynski/rgb
Last synced: about 2 months ago
JSON representation
A simple Ruby library built to handle easy conversion and manipulation of colors.
- Host: GitHub
- URL: https://github.com/plashchynski/rgb
- Owner: plashchynski
- License: apache-2.0
- Created: 2013-02-12T20:19:25.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-05-23T20:02:31.000Z (4 months ago)
- Last Synced: 2024-07-20T15:45:01.947Z (2 months ago)
- Language: Ruby
- Homepage:
- Size: 36.1 KB
- Stars: 52
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# rgb — Easy colors manipulation
------------------------
[![Gem Version](https://badge.fury.io/rb/rgb.svg)](http://badge.fury.io/rb/rgb)A simple Ruby library built to handle easy conversion and manipulation of colors. Inspired by [compass-colors](https://github.com/chriseppstein/compass-colors) and [jColour.js](https://github.com/lingo/jcolour).
## Examples
```ruby
require 'rgb'# ? Supported input data color formas:
color = RGB::Color.from_rgb_hex('#333333')
color = RGB::Color.from_rgb_hex(0xFF0000)
color = RGB::Color.from_rgb(115, 38, 38)
color = RGB::Color.from_fractions(0, 1.0, 0.5) # HSL# ? Supported color manipulations:
color.darken(20)
color.darken_percent(10)
color.darken!(20)
color.darken_percent!(10)
color.lighten(20)
color.lighten_percent(20)
color.lighten!(20)
color.lighten_percent!(20)
color.saturate(20)
color.saturate_percent(20)
color.saturate!(20)
color.saturate_percent!(20)
color.desaturate(20)
color.desaturate_percent(20)
color.desaturate!(20)
color.desaturate_percent!(20)color.invert!
# ? Mixing colors:
color.mix(other_color, 20) # ? Mix 20% of other color into current one
color.mix(other_color) # ? 50% by default
color.mix!(other_color, 20)
color.mix!(other_color)# ? Also you can adjust color HSL (hue, saturation, and lightness values) manually:
color.hue = 0.1
color.saturation = 0.2
color.lightness = 0.3# ? Supported output formats:
color.to_rgb_hex
=> '#732626'
color.to_hsl
=> [0, 1.0, 0.5]
color.to_rgb
=> [115, 38, 38]
```## Support
Feel free to create [issues](https://github.com/plashchynski/rgb/issues)
## License
Please see [LICENSE](https://github.com/plashchynski/rgb/blob/master/LICENSE) for licensing details.