Class: Term::ANSIColor::RGBColorMetrics::YUV::YUVTriple

Inherits:
Struct
  • Object
show all
Includes:
Term::ANSIColor::RGBColorMetricsHelpers::WeightedEuclideanDistance
Defined in:
lib/term/ansicolor/rgb_color_metrics.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Term::ANSIColor::RGBColorMetricsHelpers::WeightedEuclideanDistance

#weighted_euclidean_distance_to

Instance Attribute Details

#uObject

Returns the value of attribute u

Returns:

  • (Object)

    the current value of u



76
77
78
# File 'lib/term/ansicolor/rgb_color_metrics.rb', line 76

def u
  @u
end

#vObject

Returns the value of attribute v

Returns:

  • (Object)

    the current value of v



76
77
78
# File 'lib/term/ansicolor/rgb_color_metrics.rb', line 76

def v
  @v
end

#yObject

Returns the value of attribute y

Returns:

  • (Object)

    the current value of 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