Module: SimpleColor::RGB::Utils
- Included in:
- SimpleColor::RGB
- Defined in:
- lib/simplecolor/rgb.rb
Instance Method Summary collapse
-
#color256_to_rgb(c) ⇒ Object
c=16 + 36 × r + 6 × g + b.
- #rgb_random ⇒ Object
- #rgb_values(c) ⇒ Object
Instance Method Details
#color256_to_rgb(c) ⇒ Object
c=16 + 36 × r + 6 × g + b
75 76 77 78 79 |
# File 'lib/simplecolor/rgb.rb', line 75 def color256_to_rgb(c) bgr=(c-16).digits(6) bgr+=[0]*(3-rgb.length) bgr.reverse end |
#rgb_random ⇒ Object
70 71 72 |
# File 'lib/simplecolor/rgb.rb', line 70 def rgb_random RGB.new((1..3).map { Random.rand(256) }) end |
#rgb_values(c) ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/simplecolor/rgb.rb', line 81 def rgb_values(c) case c when self c.to_truecolor.color else self.parse(c).to_truecolor.color end end |