Project

color_code

0.0
No commit activity in last 3 years
No release in over 3 years
classes to handle the color code
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.8
~> 10.0
>= 0
 Project Readme

ColorCode

simple handle the color code

Installation

Add this line to your application's Gemfile:

gem 'color_code'

And then execute:

$ bundle

Or install it yourself as:

$ gem install color_code

Usage

RGB class

rgb = ColorCode::RGB.new(r: 255, g: 0, b: 0)
rgb.to_s # => '#ff0000'
rbg.to_hash # => { r: 255, g: 0, b: 0 }

HSV class

hsv = ColorCode::HSV.new(h: 0, s: 100, v: 100)
hsv.to_s # => '#ff0000'
hsv.to_hash # => { h: 0, s: 100, v: 100 }

HSL class

hsl = ColorCode::HSL.new(h: 0, s: 100, l: 50)
hsl.to_s # => '#ff0000'
hsl.to_hash # => { h: 0, s: 100, l: 50 }

convert RGB to HSV

rgb = ColorCode::RGB.new(r: 255, g: 0, b: 0)
rgb.to_s # => '#ff0000'
hsv = rgb.to_hsv
hsv.to_s # => '#ff0000'

convert HSL to RGB

hsv = ColorCode::HSV.new(h: 0, s: 100, v: 100)
hsv.to_s # => '#ff0000'
rgb = hsv.to_rgb
rgb.to_s # => '#ff0000'

convert RGB to HSL

rgb = ColorCode::RGB.new(r: 255, g: 0, b: 0)
rgb.to_s # => '#ff0000'
hsl = rgb.to_hsl
hsl.to_s # => '#ff0000'

convert HSL to RGB

hsl = ColorCode::HSL.new(h: 0, s: 100, l: 50)
hsl.to_s # => '#ff0000'
rgb = hsl.to_rgb
rgb.to_s # => '#ff0000'

Contributing

  1. Fork it ( https://github.com/shiro16/color_code/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request