ColourConversions

public static class ColourConversions
Provides static methods for converting one colour space into another. These methods have been implemented based on http://www.easyrgb.com/index.php?X=MATH and do not depend on code in Eto, Rhino, or any other assembly.

Fields

XLimit

#
public const float XLimit = 95.047

YLimit

#
public const float YLimit = 100

ZLimit

#
public const float ZLimit = 108.883

Methods

ApplyAdjective

#
Apply an adjective to a colour.
public static Color ApplyAdjective(
Color
colour,
Colour to modify.
adjective
Adjective to apply.
)
Modified colour.

Cmy_Rgb

#
Convert RGB channels into CMY channels.
public static void Cmy_Rgb(
c,
m,
y,
out double
r,
out double
g,
out double
b
)

Cmy_Rgb

#
Convert RGB channels into CMY channels.
public static void Cmy_Rgb(
c,
m,
y,
out float
r,
out float
g,
out float
b
)

Cmyk_Rgb

#
Convert CMYK channels into RGB channels.
public static void Cmyk_Rgb(
c,
m,
y,
k,
out double
r,
out double
g,
out double
b
)

Cmyk_Rgb

#
Convert CMYK channels into RGB channels.
public static void Cmyk_Rgb(
c,
m,
y,
k,
out float
r,
out float
g,
out float
b
)

Hsl_Rgb

#
Convert HSL channels into Standard RGB channels.
public static void Hsl_Rgb(
h,
s,
l,
out double
r,
out double
g,
out double
b
)

Hsl_Rgb

#
Convert HSL channels into Standard RGB channels.
public static void Hsl_Rgb(
h,
s,
l,
out float
r,
out float
g,
out float
b
)

Hsp_Rgb

#
Convert HSP (perceived luminance) channels into RGB channels.
public static void Hsp_Rgb(
hue,
sat,
lum,
out double
r,
out double
g,
out double
b
)

Hsp_Rgb

#
Convert HSP (perceived luminance) channels into RGB channels.
public static void Hsp_Rgb(
hue,
sat,
lum,
out float
r,
out float
g,
out float
b
)

Hsv_Rgb

#
Convert HSV/B channels into Standard RGB channels.
public static void Hsv_Rgb(
hue,
sat,
val,
out double
r,
out double
g,
out double
b
)

Hsv_Rgb

#
Convert HSV/B channels into Standard RGB channels.
public static void Hsv_Rgb(
hue,
sat,
val,
out float
r,
out float
g,
out float
b
)

Lab_Xyz

#
Convert Cie L*a*b* channels into Cie XYZ channels.
public static void Lab_Xyz(
l,
Luminance channel.
a,
Chroma a channel.
b,
Chroma b channel.
out double
x,
X value, up to 95.047, Observer= 2°, Illuminant= D65
out double
y,
Y value, up to 100.000
out double
z
Z value, up to 108.883
)

Lab_Xyz

#
Convert Cie L*a*b* channels into Cie XYZ channels.
public static void Lab_Xyz(
l,
Luminance channel.
a,
Chroma a channel.
b,
Chroma b channel.
out float
x,
X value, up to 95.047, Observer= 2°, Illuminant= D65
out float
y,
Y value, up to 100.000
out float
z
Z value, up to 108.883
)

MapYxyPlanckianLoci

#
Compute the points for key temperatures along the black body curve of the CIE Chromaticity diagram.
public static ColourConversions.PlanckianLocus[] MapYxyPlanckianLoci(
RectangleF
frame
Target frame for Yxy graph.
)
Temperature measure array.

MapYxyPlanckianLocus

#
Compute the points for a degree=3 bezier curve describing the black body curve of the CIE Chromaticity diagram.
public static PointF[] MapYxyPlanckianLocus(
RectangleF
frame
Target frame for Yxy graph.
)
Point array.

MapYxyRgbGamut

#
Compute the cornerpoints of the sRGB gamut triangle within the CIE Chromaticity diagram.
public static void MapYxyRgbGamut(
RectangleF
frame,
Target frame for Yxy graph.
out PointF
red,
Red corner.
out PointF
green,
Green corner.
out PointF
blue
Blue corner.
)

MapYxySpectralLoci

#
Compute the points for key wavelengths along the spectral curve of the CIE Chromaticity diagram.
public static ColourConversions.SpectralLocus[] MapYxySpectralLoci(
RectangleF
frame
Target frame for Yxy graph.
)
Wavelength measure array.

MapYxySpectralLocus

#
Compute the points for a degree=3 bezier curve describing the spectral curve of the CIE Chromaticity diagram.
public static PointF[] MapYxySpectralLocus(
RectangleF
frame
Target frame for Yxy graph.
)
Point array.

MixColourNames

#
Mix two colours using the linguistic parser logic. This method interpolates between the colours inside the Sinusoidal model.
public static Color MixColourNames(
Color
a,
First colour.
Color
b
Second colour.
)
Midway colour.

Oklab_Oklch

#
Convert Oklab channels into their polar Oklch form.
public static void Oklab_Oklch(
a,
Green-red opposition channel.
b,
Blue-yellow opposition channel.
out double
chroma,
Chroma, the distance from the neutral axis.
out double
hue
Hue in degrees, 0 to 360.
)

Oklab_RgbLinear

#
Convert Oklab channels into linear RGB channels.
public static void Oklab_RgbLinear(double L, double a, double b, out double r, out double g, out double bʹ)
L (double)Perceptual lightness, 0 to 1.
a (double)Green-red opposition channel.
b (double)Blue-yellow opposition channel.
r (out double)Linear red channel.
g (out double)Linear green channel.
bʹ (out double)Linear blue channel.

Oklab_RgbLinear

#
Convert Oklab channels into linear RGB channels.
public static void Oklab_RgbLinear(float L, float a, float b, out float r, out float g, out float bʹ)
L (float)Perceptual lightness, 0 to 1.
a (float)Green-red opposition channel.
b (float)Blue-yellow opposition channel.
r (out float)Linear red channel.
g (out float)Linear green channel.
bʹ (out float)Linear blue channel.

Oklch_Oklab

#
Convert polar Oklch channels into Oklab channels.
public static void Oklch_Oklab(
chroma,
Chroma, the distance from the neutral axis.
hue,
Hue in degrees.
out double
a,
Green-red opposition channel.
out double
b
Blue-yellow opposition channel.
)

Rgb_Cmy

#
Convert RGB channels into CMY channels.
public static void Rgb_Cmy(
r,
g,
b,
out double
c,
out double
m,
out double
y
)

Rgb_Cmy

#
Convert RGB channels into CMY channels.
public static void Rgb_Cmy(
r,
g,
b,
out float
c,
out float
m,
out float
y
)

Rgb_Cmyk

#
Convert standard RGB channels into CMYK channels.
public static void Rgb_Cmyk(
r,
g,
b,
out double
c,
out double
m,
out double
y,
out double
k
)

Rgb_Cmyk

#
Convert standard RGB channels into CMYK channels.
public static void Rgb_Cmyk(
r,
g,
b,
out float
c,
out float
m,
out float
y,
out float
k
)

Rgb_Hsl

#
Convert Standard RGB channels into HSL channels.
public static void Rgb_Hsl(
r,
g,
b,
out double
h,
out double
s,
out double
l
)

Rgb_Hsl

#
Convert Standard RGB channels into HSL channels.
public static void Rgb_Hsl(
r,
g,
b,
out float
h,
out float
s,
out float
l
)

Rgb_Hsp

#
Convert RGB channels into H*SP (perceived luminance) channels.
public static void Rgb_Hsp(
r,
g,
b,
out double
hue,
out double
sat,
out double
lum
)

Rgb_Hsp

#
Convert RGB channels into H*SP (perceived luminance) channels.
public static void Rgb_Hsp(
r,
g,
b,
out float
hue,
out float
sat,
out float
lum
)

Rgb_Hsv

#
Convert Standard RGB channels into HSV/B channels.
public static void Rgb_Hsv(
r,
g,
b,
out double
h,
out double
s,
out double
v
)

Rgb_Hsv

#
Convert Standard RGB channels into HSV/B channels.
public static void Rgb_Hsv(
r,
g,
b,
out float
h,
out float
s,
out float
v
)

Rgb_Hue

#
Convert an RGB triplet into an HSB/HSV/HSL hue.
public static double Rgb_Hue()
Hue angle.

Rgb_Hue

#
Convert an RGB triplet into an HSB/HSV/HSL hue.
public static float Rgb_Hue()
Hue angle.

Rgb_Xyz

#
Convert Standard RGB channels into Cie XYZ channels.
public static void Rgb_Xyz(
r,
g,
b,
out double
x,
out double
y,
out double
z
)

Rgb_Xyz

#
Convert Standard RGB channels into Cie XYZ channels.
public static void Rgb_Xyz(
r,
g,
b,
out float
x,
out float
y,
out float
z
)

RgbGammaAdjust

#
Perform a gamma correction on linear RGB channels.
public static void RgbGammaAdjust(double r, double g, double b, double exponent, out double rʹ, out double gʹ, out double bʹ)
r (double)Linear red.
g (double)Linear green.
b (double)Linear blue.
exponent (double)Exponent, 2.2 or 2.4 are common.
rʹ (out double)Gamma corrected red.
gʹ (out double)Gamma corrected green.
bʹ (out double)Gamma corrected blue.

RgbGammaAdjust

#
Perform a gamma correction on linear RGB channels.
public static void RgbGammaAdjust(float r, float g, float b, double exponent, out float rʹ, out float gʹ, out float bʹ)
r (float)Linear red.
g (float)Linear green.
b (float)Linear blue.
exponent (double)Exponent, 2.2 or 2.4 are common.
rʹ (out float)Gamma corrected red.
gʹ (out float)Gamma corrected green.
bʹ (out float)Gamma corrected blue.

RgbGammaRevert

#
Perform an inverse gamma correction on non-linear RGB channels.
public static void RgbGammaRevert(double r, double g, double b, double exponent, out double rʹ, out double gʹ, out double bʹ)
r (double)Non-linear red.
g (double)Non-linear green.
b (double)Non-linear blue.
exponent (double)Exponent, 2.2 or 2.4 are common.
rʹ (out double)Linear red.
gʹ (out double)Linear green.
bʹ (out double)Linear blue.

RgbGammaRevert

#
Perform an inverse gamma correction on non-linear RGB channels.
public static void RgbGammaRevert(float r, float g, float b, double exponent, out float rʹ, out float gʹ, out float bʹ)
r (float)Non-linear red.
g (float)Non-linear green.
b (float)Non-linear blue.
exponent (double)Exponent, 2.2 or 2.4 are common.
rʹ (out float)Linear red.
gʹ (out float)Linear green.
bʹ (out float)Linear blue.

RgbLinear_Oklab

#
Convert linear RGB channels into Oklab channels.
public static void RgbLinear_Oklab(double r, double g, double b, out double L, out double a, out double bʹ)
r (double)Linear red channel.
g (double)Linear green channel.
b (double)Linear blue channel.
L (out double)Perceptual lightness, 0 to 1.
a (out double)Green-red opposition channel.
bʹ (out double)Blue-yellow opposition channel.

RgbLinear_Oklab

#
Convert linear RGB channels into Oklab channels.
public static void RgbLinear_Oklab(float r, float g, float b, out float L, out float a, out float bʹ)
r (float)Linear red channel.
g (float)Linear green channel.
b (float)Linear blue channel.
L (out float)Perceptual lightness, 0 to 1.
a (out float)Green-red opposition channel.
bʹ (out float)Blue-yellow opposition channel.

RgbLinear_RgbStandard

#
Convert linear RGB channels to standard RGB channels.
public static void RgbLinear_RgbStandard(double r, double g, double b, out double rʹ, out double gʹ, out double bʹ)
r (double)
g (double)
b (double)
rʹ (out double)
gʹ (out double)
bʹ (out double)

RgbLinear_RgbStandard

#
Convert linear RGB channels to standard RGB channels.
public static void RgbLinear_RgbStandard(float r, float g, float b, out float rʹ, out float gʹ, out float bʹ)
r (float)
g (float)
b (float)
rʹ (out float)
gʹ (out float)
bʹ (out float)

RgbStandard_RgbLinear

#
Convert standard RGB channels to linear RGB channels.
public static void RgbStandard_RgbLinear(double r, double g, double b, out double rʹ, out double gʹ, out double bʹ)
r (double)
g (double)
b (double)
rʹ (out double)
gʹ (out double)
bʹ (out double)

RgbStandard_RgbLinear

#
Convert standard RGB channels to linear RGB channels.
public static void RgbStandard_RgbLinear(float r, float g, float b, out float rʹ, out float gʹ, out float bʹ)
r (float)
g (float)
b (float)
rʹ (out float)
gʹ (out float)
bʹ (out float)

ToAdjustedHue

#
Convert an HSV hue into an HSP hue.
public static double ToAdjustedHue(
hsvHue
Hsv hue.
)
Hsp hue.

ToAdjustedHue

#
Convert an HSV hue into an HSP hue.
public static float ToAdjustedHue(
hsvHue
Hsv hue.
)
Hsp hue.

ToTraditionalHue

#
Convert an HSP hue into an HSV hue.
public static double ToTraditionalHue(
hspHue
Hsp hue.
)
Hsp hue.

ToTraditionalHue

#
Convert an HSP hue into an HSV hue.
public static float ToTraditionalHue(
hspHue
Hsp hue.
)
Hsp hue.

TryParseNamedColour

#
Try and parse a text describing a colour by name.
public static ColourParseSource TryParseNamedColour(
text,
Text to parse.
out Color
colour,
Resulting colour.
includeFuzzyParsing,
If true, near hits are allowed.
includeMixedParsing
If true, combinations of names are allowed.
)

Xyz_Lab

#
Convert Cie XYZ channels into Cie L*a*b* channels.
public static void Xyz_Lab(
x,
X value, up to 95.047, Observer= 2°, Illuminant= D65
y,
Y value, up to 100.000
z,
Z value, up to 108.883
out double
l,
Luminance channel.
out double
a,
Chroma a channel.
out double
b
Chroma b channel.
)

Xyz_Lab

#
Convert Cie XYZ channels into Cie L*a*b* channels.
public static void Xyz_Lab(
x,
X value, up to 95.047, Observer= 2°, Illuminant= D65
y,
Y value, up to 100.000
z,
Z value, up to 108.883
out float
l,
Luminance channel.
out float
a,
Chroma a channel.
out float
b
Chroma b channel.
)

Xyz_Rgb

#
Convert Cie XYZ channels into Standard RGB channels. Note that the RGB values are neither clipped nor tonemapped, so they may well exceed the [0~1] range.
public static void Xyz_Rgb(
x,
y,
z,
out double
r,
out double
g,
out double
b
)

Xyz_Rgb

#
Convert Cie XYZ channels into Standard RGB channels. Note that the RGB values are neither clipped nor tonemapped, so they may well exceed the [0~1] range.
public static void Xyz_Rgb(
x,
y,
z,
out float
r,
out float
g,
out float
b
)

Xyz_Yxy

#
Convert Cie XYZ channels into Cie Chromaticity diagram channels.
public static void Xyz_Yxy(
x,
X value, up to 95.047, Observer= 2°, Illuminant= D65
y,
Y value, up to 100.000
z,
Z value, up to 108.883
out double
Y,
out double
Yx,
out double
Yy
)

Xyz_Yxy

#
Convert Cie XYZ channels into Cie Chromaticity diagram channels.
public static void Xyz_Yxy(
x,
X value, up to 95.047, Observer= 2°, Illuminant= D65
y,
Y value, up to 100.000
z,
Z value, up to 108.883
out float
Y,
out float
Yx,
out float
Yy
)

Yxy_Xyz

#
Convert Cie Chromaticity Diagram channels into Cie XYZ channels.
public static void Yxy_Xyz(
Y,
Chromaticity luminance.
Yx,
Chromaticity x.
Yy,
Chromaticity y.
out double
x,
X value, up to 95.047, Observer= 2°, Illuminant= D65
out double
y,
Y value, up to 100.000
out double
z
Z value, up to 108.883
)

Yxy_Xyz

#
Convert Cie Chromaticity Diagram channels into Cie XYZ channels.
public static void Yxy_Xyz(
Y,
Chromaticity luminance.
Yx,
Chromaticity x.
Yy,
Chromaticity y.
out float
x,
X value, up to 95.047, Observer= 2°, Illuminant= D65
out float
y,
Y value, up to 100.000
out float
z
Z value, up to 108.883
)