Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
ColorConverter Class Reference

Static Public Member Functions

static Lab RgbToLab (Color rgb)
 
static Lab XyzToLab (Xyz xyz)
 
static Xyz RgbToXyz (Color rgb)
 

Static Private Member Functions

static float PivotXyz (float n)
 
static float CubicRoot (float n)
 
static float PivotRgb (float n)
 

Static Private Attributes

const float Epsilon = 0.008856f
 
const float Kappa = 903.3f
 
static readonly Xyz WhiteReference
 

Detailed Description

Definition at line 4 of file ColorConverter.cs.

Member Function Documentation

◆ CubicRoot()

static float ColorConverter.CubicRoot ( float  n)
inlinestaticprivate

Definition at line 45 of file ColorConverter.cs.

46 {
47 return Mathf.Pow(n, 1f / 3f);
48 }

Referenced by PivotXyz().

◆ PivotRgb()

static float ColorConverter.PivotRgb ( float  n)
inlinestaticprivate

Definition at line 63 of file ColorConverter.cs.

64 {
65 return ((n > 0.04045f) ? Mathf.Pow((n + 0.055f) / 1.055f, 2.4f) : (n / 12.92f)) * 100f;
66 }

Referenced by RgbToXyz().

◆ PivotXyz()

static float ColorConverter.PivotXyz ( float  n)
inlinestaticprivate

Definition at line 36 of file ColorConverter.cs.

37 {
38 if (!(n > 0.008856f))
39 {
40 return (903.3f * n + 16f) / 116f;
41 }
42 return CubicRoot(n);
43 }
static float CubicRoot(float n)

References CubicRoot().

Referenced by XyzToLab().

◆ RgbToLab()

static Lab ColorConverter.RgbToLab ( Color  rgb)
inlinestatic

Definition at line 17 of file ColorConverter.cs.

18 {
19 return XyzToLab(RgbToXyz(rgb));
20 }
static Lab XyzToLab(Xyz xyz)
static Xyz RgbToXyz(Color rgb)

References RgbToXyz(), and XyzToLab().

Referenced by ColorComparer.Compare().

◆ RgbToXyz()

static Xyz ColorConverter.RgbToXyz ( Color  rgb)
inlinestatic

Definition at line 50 of file ColorConverter.cs.

51 {
52 float num = PivotRgb(rgb.r);
53 float num2 = PivotRgb(rgb.g);
54 float num3 = PivotRgb(rgb.b);
55 return new Xyz
56 {
57 X = num * 0.4124f + num2 * 0.3576f + num3 * 0.1805f,
58 Y = num * 0.2126f + num2 * 0.7152f + num3 * 0.0722f,
59 Z = num * 0.0193f + num2 * 0.1192f + num3 * 0.9505f
60 };
61 }
static float PivotRgb(float n)
Definition: Xyz.cs:2

References PivotRgb().

Referenced by RgbToLab().

◆ XyzToLab()

static Lab ColorConverter.XyzToLab ( Xyz  xyz)
inlinestatic

Definition at line 22 of file ColorConverter.cs.

23 {
24 Xyz whiteReference = WhiteReference;
25 float num = PivotXyz(xyz.X / whiteReference.X);
26 float num2 = PivotXyz(xyz.Y / whiteReference.Y);
27 float num3 = PivotXyz(xyz.Z / whiteReference.Z);
28 return new Lab
29 {
30 L = Math.Max(0f, 116f * num2 - 16f),
31 A = 500f * (num - num2),
32 B = 200f * (num2 - num3)
33 };
34 }
static float PivotXyz(float n)
static readonly Xyz WhiteReference
Definition: Lab.cs:2
float Y
Definition: Xyz.cs:5
float Z
Definition: Xyz.cs:7
float X
Definition: Xyz.cs:3

References PivotXyz(), WhiteReference, Xyz.X, Xyz.Y, and Xyz.Z.

Referenced by RgbToLab().

Member Data Documentation

◆ Epsilon

const float ColorConverter.Epsilon = 0.008856f
staticprivate

Definition at line 6 of file ColorConverter.cs.

◆ Kappa

const float ColorConverter.Kappa = 903.3f
staticprivate

Definition at line 8 of file ColorConverter.cs.

◆ WhiteReference

readonly Xyz ColorConverter.WhiteReference
staticprivate
Initial value:
= new Xyz
{
X = 95.047f,
Y = 100f,
Z = 108.883f
}

Definition at line 10 of file ColorConverter.cs.

Referenced by XyzToLab().


The documentation for this class was generated from the following file: