Class: Colorspace::SRGBColor
- Inherits:
-
Object
- Object
- Colorspace::SRGBColor
- Defined in:
- lib/colorspace/colorlib.rb
Overview
An RGB value in the sRGB colorspace.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_hex(hex) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/colorspace/colorlib.rb', line 73 def self.from_hex(hex) r, g, b = hex.chars.last(6).each_slice(2) .map { |c| c.join.to_i(16) / 255.0 } new(r: r || 0.0, g: g || 0.0, b: b || 0.0) end |
Instance Method Details
#gamma_expand ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/colorspace/colorlib.rb', line 98 def SRGBLinearColor.new( r: (r), g: (g), b: (b) ) end |
#to_a ⇒ Object
107 |
# File 'lib/colorspace/colorlib.rb', line 107 def to_a = to_ary |
#to_ary ⇒ Object
106 |
# File 'lib/colorspace/colorlib.rb', line 106 def to_ary = [r, g, b] |
#to_hex ⇒ Object
80 81 82 83 84 |
# File 'lib/colorspace/colorlib.rb', line 80 def to_hex [r, g, b].map { |val| (val * 255).round.clamp(0, 255).to_s(16).rjust(2, '0') }.join end |
#to_xyz ⇒ Object
94 95 96 |
# File 'lib/colorspace/colorlib.rb', line 94 def to_xyz .to_xyz end |