### Home Classes Methods

### In Files

- lib/term/ansicolor/rgb_color_metrics.rb

### Parent

Struct.new(:l, :a, :b)

### Methods

- ::from_rgb_triple

### Included Modules

- Term::ANSIColor::RGBColorMetricsHelpers::WeightedEuclideanDistance

### 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::CIELab::CIELabTriple

### Public Class Methods

from_rgb_triple(rgb_triple) click to toggle source

    # File lib/term/ansicolor/rgb_color_metrics.rb, line 127
    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

      xr = x / 0.964221
      yr = y
      zr = z / 0.825211

      eps = 216.0 / 24389
      k = 24389.0 / 27

      fx = xr > eps ? xr ** (1.0 / 3) : (k * xr + 16) / 116
      fy = yr > eps ? yr ** (1.0 / 3) : (k * yr + 16) / 116
      fz = zr > eps ? zr ** (1.0 / 3) : (k * zr + 16) / 116

      l = 2.55 * ((116 * fy) - 16)
      a = 500 * (fx - fy)
      b = 200 * (fy - fz)

      new(l.round, a.round, b.round)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.