Class: Termin::ANSIColor::RGBColorMetrics::CIEXYZ::CIEXYZTriple
- Inherits:
-
Struct
- Object
- Struct
- Termin::ANSIColor::RGBColorMetrics::CIEXYZ::CIEXYZTriple
- Defined in:
- lib/termin/ansicolor/rgb_color_metrics.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
-
#z ⇒ Object
Returns the value of attribute z.
Class Method Summary collapse
Methods included from Termin::ANSIColor::RGBColorMetricsHelpers::WeightedEuclideanDistance
#weighted_euclidean_distance_to
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x
96 97 98 |
# File 'lib/termin/ansicolor/rgb_color_metrics.rb', line 96 def x @x end |
#y ⇒ Object
Returns the value of attribute y
96 97 98 |
# File 'lib/termin/ansicolor/rgb_color_metrics.rb', line 96 def y @y end |
#z ⇒ Object
Returns the value of attribute 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 |