Class: Kolors::Rgb

Inherits:
Object
  • Object
show all
Defined in:
lib/kolors/rgb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(r, g, b) ⇒ Rgb

Returns a new instance of Rgb.



6
7
8
9
10
# File 'lib/kolors/rgb.rb', line 6

def initialize(r,g,b)
  @r = r
  @g = g
  @b = b
end

Instance Attribute Details

#aObject (readonly)

Returns the value of attribute a.



4
5
6
# File 'lib/kolors/rgb.rb', line 4

def a
  @a
end

#bObject (readonly)

Returns the value of attribute b.



3
4
5
# File 'lib/kolors/rgb.rb', line 3

def b
  @b
end

#gObject (readonly)

Returns the value of attribute g.



3
4
5
# File 'lib/kolors/rgb.rb', line 3

def g
  @g
end

#lObject (readonly)

Returns the value of attribute l.



4
5
6
# File 'lib/kolors/rgb.rb', line 4

def l
  @l
end

#rObject (readonly)

Returns the value of attribute r.



3
4
5
# File 'lib/kolors/rgb.rb', line 3

def r
  @r
end

Instance Method Details

#to_labObject

EasyRGB - RGB to LAB

  • LAB gives us a perceptually accurate colorspace



14
15
16
17
# File 'lib/kolors/rgb.rb', line 14

def to_lab
  x,y,z = rgb_to_xyz(@r,@g,@b)
  l,a,b = xyz_to_lab(x,y,z)
end