Module: Termin::ANSIColor::RGBColorMetrics::CompuPhase

Defined in:
lib/termin/ansicolor/rgb_color_metrics.rb

Overview

Implements color distance as given in:

http://www.compuphase.com/cmetric.htm

Class Method Summary collapse

Class Method Details

.distance(rgb1, rgb2) ⇒ Object



68
69
70
71
72
# File 'lib/termin/ansicolor/rgb_color_metrics.rb', line 68

def self.distance(rgb1, rgb2)
  rmean = (rgb1.red + rgb2.red) / 2
  rgb1.weighted_euclidean_distance_to rgb2,
      [ 2 + (rmean >> 8), 4, 2 + ((255 - rmean) >> 8) ]
end