Class: Termin::ANSIColor::RGBColorMetrics::CIEXYZ::CIEXYZTriple

Inherits:
Struct
  • Object
show all
Extended by:
Termin::ANSIColor::RGBColorMetricsHelpers::NormalizeRGBTriple
Includes:
Termin::ANSIColor::RGBColorMetricsHelpers::WeightedEuclideanDistance
Defined in:
lib/termin/ansicolor/rgb_color_metrics.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Termin::ANSIColor::RGBColorMetricsHelpers::WeightedEuclideanDistance

#weighted_euclidean_distance_to

Instance Attribute Details

#xObject

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



96
97
98
# File 'lib/termin/ansicolor/rgb_color_metrics.rb', line 96

def x
  @x
end

#yObject

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



96
97
98
# File 'lib/termin/ansicolor/rgb_color_metrics.rb', line 96

def y
  @y
end

#zObject

Returns the value of attribute z

Returns:

  • (Object)

    the current value of z



96
97
98
# File 'lib/termin/ansicolor/rgb_color_metrics.rb', line 96

def z
  @z
end

Class Method Details

.from_rgb_triple(rgb_triple) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/termin/ansicolor/rgb_color_metrics.rb', line 100

def self.from_rgb_triple(rgb_triple)
  r, g, b = normalize_rgb_triple rgb_triple

  x =  0.436052025 * r + 0.385081593 * g + 0.143087414 * b
  y =  0.222491598 * r + 0.71688606  * g + 0.060621486 * b
  z =  0.013929122 * r + 0.097097002 * g + 0.71418547  * b

  x *= 255
  y *= 255
  z *= 255

  new(x.round, y.round, z.round)
end