Class: Term::ANSIColor::RGBColorMetrics::YUV::YUVTriple
- Inherits:
-
Struct
- Object
- Struct
- Term::ANSIColor::RGBColorMetrics::YUV::YUVTriple
- Defined in:
- lib/term/ansicolor/rgb_color_metrics.rb
Instance Attribute Summary collapse
-
#u ⇒ Object
Returns the value of attribute u.
-
#v ⇒ Object
Returns the value of attribute v.
-
#y ⇒ Object
Returns the value of attribute y.
Class Method Summary collapse
Methods included from Term::ANSIColor::RGBColorMetricsHelpers::WeightedEuclideanDistance
#weighted_euclidean_distance_to
Instance Attribute Details
#u ⇒ Object
Returns the value of attribute u
76 77 78 |
# File 'lib/term/ansicolor/rgb_color_metrics.rb', line 76 def u @u end |
#v ⇒ Object
Returns the value of attribute v
76 77 78 |
# File 'lib/term/ansicolor/rgb_color_metrics.rb', line 76 def v @v end |
#y ⇒ Object
Returns the value of attribute y
76 77 78 |
# File 'lib/term/ansicolor/rgb_color_metrics.rb', line 76 def y @y end |
Class Method Details
.from_rgb_triple(rgb_triple) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/term/ansicolor/rgb_color_metrics.rb', line 79 def self.from_rgb_triple(rgb_triple) r, g, b = rgb_triple.red, rgb_triple.green, rgb_triple.blue y = (0.299 * r + 0.587 * g + 0.114 * b).round u = ((b - y) * 0.492).round v = ((r - y) * 0.877).round new(y, u, v) end |