Module: SimpleColor::RGB::Utils

Included in:
SimpleColor::RGB
Defined in:
lib/simplecolor/rgb.rb

Instance Method Summary collapse

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_randomObject



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