struct Foundation::Lab

Overview

A CIELAB color using D65 reference white. Used for perceptual color distance. References for color constants and calculations for sRGB D65

Meta: Reopened so these methods live outside the record macro block but are still attached to the same struct. Why do this? Because the crystal docs commands' wants_doc parser chokes on method docstring comments under the record macro.

Defined in:

foundation/color_space.cr:18
foundation/color_space.cr:23

Constructors

Instance Method Summary

Constructor Detail

def self.new(l : Float64, a : Float64, b : Float64) #

[View source]

Instance Method Detail

def a : Float64 #

def b : Float64 #

def clone #

[View source]
def copy_with(l _l = @l, a _a = @a, b _b = @b) #

[View source]
def distance(other : Lab) : Float64 #

ΔE76: the Euclidean distance between two Lab colors. Larger is more perceptually different.


[View source]
def l : Float64 #

def to_rgb : RGB #

Inverse of RGB#to_lab, converts this CIELAB color back to 8bit sRGB (D65).

Out-of-gamut Lab values are clamped into the sRGB cube, so this method always returns a valid RGB and never raises. A round-trip may differ by +/-1 per channel because each trip rounds the conversion independently.


[View source]