### Home Classes Methods

### In Files

- lib/term/ansicolor/rgb_color_metrics.rb

### Methods

- ::distance

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Term
- Term::ANSIColor
- Term::ANSIColor::Attribute
- Term::ANSIColor::PPMReader
- Term::ANSIColor::RGBColorMetrics
- Term::ANSIColor::RGBColorMetrics::CIELab
- Term::ANSIColor::RGBColorMetrics::CIELab::CIELabTriple
- Term::ANSIColor::RGBColorMetrics::CIEXYZ
- Term::ANSIColor::RGBColorMetrics::CIEXYZ::CIEXYZTriple
- Term::ANSIColor::RGBColorMetrics::CompuPhase
- Term::ANSIColor::RGBColorMetrics::Euclidean
- Term::ANSIColor::RGBColorMetrics::NTSC
- Term::ANSIColor::RGBColorMetrics::YUV
- Term::ANSIColor::RGBColorMetrics::YUV::YUVTriple
- Term::ANSIColor::RGBColorMetricsHelpers
- Term::ANSIColor::RGBColorMetricsHelpers::NormalizeRGBTriple
- Term::ANSIColor::RGBColorMetricsHelpers::WeightedEuclideanDistance
- Term::ANSIColor::RGBTriple

No matching classes.

# Term::ANSIColor::RGBColorMetrics::CompuPhase

Implements color distance as given in:

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

### Public Class Methods

distance(rgb1, rgb2) click to toggle source

    # File lib/term/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

[Validate]

Generated with the Darkfish Rdoc Generator 2.