Color
Float RGBA components; alpha and color encoding depend on how the value is used.
A struct with four float components: R, G, B and A. Color(r, g, b, a) stores them; omitting a uses 1. default(Color) has four zeros, including A = 0. Components are not automatically restricted to 0..1: the receiving API determines accepted values and color space.
The type stores no sRGB/linear tag. Use SrgbToLinear() and LinearToSrgb() only when you know the input encoding and recipient requirements.
Color has no C# conversion to bool. Compare A explicitly when testing the alpha channel; this is not a universal object-visibility test. RGB and A remain separate data.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors6
Color6 overloads
public Color(Color c, float a = 1f);Copies only RGB from c and replaces alpha with a. new Color(c) sets alpha to 1 even when c is transparent. For an exact struct copy use Color copy = c.
| Name | Type | Default |
|---|---|---|
c | Color | — |
a | float | 1f |
cRGB source; its alpha is ignored.
aUnclamped alpha; normally 0…1. Defaults to 1.
public Color(float r, float g, float b, float a = 1f);Stores RGBA unchanged, without range clamping or color-space conversion. Omitting a sets alpha to 1, unlike default(Color), whose four components are all 0.
| Name | Type | Default |
|---|---|---|
r | float | — |
g | float | — |
b | float | — |
a | float | 1f |
rUnclamped R component; normally 0…1.
gUnclamped G component; normally 0…1.
bUnclamped B component; normally 0…1.
aUnclamped alpha; normally 0…1. Defaults to 1.
public Color(string code);Parses a valid HTML code or Colors name. Names ignore case and remove spaces, hyphens, underscores, apostrophes and periods. Unknown input throws ArgumentOutOfRangeException. For user input use FromString with a fallback, or HtmlIsValid before FromHtml.
| Name | Type | Default |
|---|---|---|
code | string | — |
codeRGB/RGBA HTML code with 3, 4, 6 or 8 hex digits and optional #, or a Colors name.
public Color(string code, float alpha);Parses code as Color(string), then replaces its alpha with alpha without clamping. Alpha in the HTML code is replaced, not multiplied. Invalid input throws ArgumentOutOfRangeException.
| Name | Type | Default |
|---|---|---|
code | string | — |
alpha | float | — |
codeRGB/RGBA HTML code with 3, 4, 6 or 8 hex digits and optional #, or a Colors name.
alphaNew alpha replacing the value from code; normally 0…1.
public Color(uint rgba);Reads 0xRRGGBBAA: 8 bits per channel, R in the high bits and A in the low bits. Divides each channel by 255. This is integer bit order, not memory byte order. A 24-bit RGB value without alpha is not this format: use new Color(0xff0000ffU) for red.
| Name | Type | Default |
|---|---|---|
rgba | uint | — |
rgbaUnsigned 0xRRGGBBAA value.
public Color(ulong rgba);Reads 0xRRRRGGGGBBBBAAAA: 16 bits per channel, R in the high bits and A in the low bits. Divides each channel by 65535. This is integer bit order, not memory byte order. ToRgba64 preserves the tested 16-bit channels.
| Name | Type | Default |
|---|---|---|
rgba | ulong | — |
rgbaUnsigned 0xRRRRGGGGBBBBAAAA value.
Properties12
A8Property
public int A8 { get; set; }Reads (int)Math.Round(A * 255), with midpoints rounded to even. Writes A = value / 255f. This is int, not byte; it does not clamp to 0…255: writing 510 sets the component to 2. Use the valid range and finite values for ordinary 8-bit colors.
B8Property
public int B8 { get; set; }Reads (int)Math.Round(B * 255), with midpoints rounded to even. Writes B = value / 255f. This is int, not byte; it does not clamp to 0…255: writing 510 sets the component to 2. Use the valid range and finite values for ordinary 8-bit colors.
G8Property
public int G8 { get; set; }Reads (int)Math.Round(G * 255), with midpoints rounded to even. Writes G = value / 255f. This is int, not byte; it does not clamp to 0…255: writing 510 sets the component to 2. Use the valid range and finite values for ordinary 8-bit colors.
HProperty
public float H { get; set; }HSV hue in turns; 0…1 for ordinary RGB. Returns 0 when R, G and B are equal: gray has no separately stored hue. Setting reconstructs RGB through FromHsv(value, S, V, A), preserving alpha. Normalize negative hues before setting.
ItemProperty
public float this[int index] { get; set; }RGBA indexer: 0 → R, 1 → G, 2 → B, 3 → A. Reading or writing outside 0…3 throws ArgumentOutOfRangeException. Writing does not clamp the channel value.
LuminanceProperty
public float Luminance { get; }Computes 0.2126 * R + 0.7152 * G + 0.0722 * B, ignoring alpha. RGB must be linear to obtain relative luminance; for sRGB use color.SrgbToLinear().Luminance. The result is not clamped to 0…1: RGB = (2, 2, 2) yields 2. Alone this is not a text accessibility or background contrast test.
OkHslHProperty
public float OkHslH { get; set; }OKHSL hue computed from current sRGB. Native reading clamps the result to 0…1 and replaces a NaN result with 0. Hue is measured in turns, not degrees. Setting reconstructs RGB through FromOkHsl, retaining current OkHslS, OkHslL within conversion precision. This clamps all RGBA to 0…1: setting only OkHslH may still change a previously out-of-range alpha. Do not use to preserve HDR range.
OkHslLProperty
public float OkHslL { get; set; }OKHSL lightness computed from current sRGB. Native reading clamps the result to 0…1 and replaces a NaN result with 0. Setting reconstructs RGB through FromOkHsl, retaining current OkHslH, OkHslS within conversion precision. This clamps all RGBA to 0…1: setting only OkHslL may still change a previously out-of-range alpha. Do not use to preserve HDR range.
OkHslSProperty
public float OkHslS { get; set; }OKHSL saturation computed from current sRGB. Native reading clamps the result to 0…1 and replaces a NaN result with 0. Setting reconstructs RGB through FromOkHsl, retaining current OkHslH, OkHslL within conversion precision. This clamps all RGBA to 0…1: setting only OkHslS may still change a previously out-of-range alpha. Do not use to preserve HDR range.
R8Property
public int R8 { get; set; }Reads (int)Math.Round(R * 255), with midpoints rounded to even. Writes R = value / 255f. This is int, not byte; it does not clamp to 0…255: writing 510 sets the component to 2. Use the valid range and finite values for ordinary 8-bit colors.
SProperty
public float S { get; set; }HSV saturation: (max(R,G,B) − min(R,G,B)) / max(R,G,B), or 0 when the maximum is zero. Normally 0…1 for RGB in 0…1. Setting reconstructs RGB through FromHsv(H, value, V, A), preserving alpha; the value is not clamped.
VProperty
public float V { get; set; }HSV value: max(R, G, B). This is not Luminance and is not bounded by 1: RGB = (2, 1, 0) has V = 2. Setting reconstructs RGB through FromHsv(H, S, value, A), preserving alpha; the value is not clamped.
Methods44
BlendColor
public Color Blend(Color over);Composites the foreground over onto this background using straight, not premultiplied, alpha. For alpha in 0…1, output A = background.A * (1 − foreground.A) + foreground.A; RGB is normalized by output A. Returns (0, 0, 0, 0) when output A is 0.
Order matters: background.Blend(foreground). Operates on supplied RGB numbers without sRGB-to-linear conversion or channel clamping. To composite sRGB inputs in linear light:
using Reckfell;
public static class SrgbColorOperations
{
// Inputs: sRGB RGB values and straight alpha, all finite and in 0..1.
// Output: sRGB RGB values and straight alpha.
public static Color Composite(Color background, Color foreground)
{
Color backgroundLinear = background.SrgbToLinear();
Color foregroundLinear = foreground.SrgbToLinear();
return backgroundLinear.Blend(foregroundLinear).LinearToSrgb();
}
}| Name | Type | Default |
|---|---|---|
over | Color | — |
overForeground with straight alpha; this color is the background.
ColorNew straight-alpha color; input colors remain unchanged.
ClampColor
public Color Clamp(Color? min = default, Color? max = default);Returns a copy with each RGBA component clamped through Mathf.Clamp. Defaults to min = (0, 0, 0, 0), max = (1, 1, 1, 1). Each channel has independent bounds; min above max throws ArgumentException. This is not HDR tone mapping and does not repair NaN.
| Name | Type | Default |
|---|---|---|
min | Color? | default |
max | Color? | default |
minLower RGBA bounds; null means four zeros.
maxUpper RGBA bounds; null means four ones.
ColorCopy with clamped channels.
Color8Color
public static Color Color8(byte r8, byte g8, byte b8, byte a8 = 255);Creates RGBA from four bytes by dividing each by 255. Omitting a8 uses 255, making the color opaque. Does not convert between sRGB and linear.
| Name | Type | Default |
|---|---|---|
r8 | byte | — |
g8 | byte | — |
b8 | byte | — |
a8 | byte | 255 |
r8R channel, integer 0…255.
g8G channel, integer 0…255.
b8B channel, integer 0…255.
a8A channel, integer 0…255. Defaults to 255.
ColorColor with channels in 0…1.
DarkenedColor
public Color Darkened(float amount);Darkens RGB using RGB * (1 − amount), preserving A. At amount = 0 the color is unchanged; at 1 RGB becomes black. amount is not clamped: values outside 0…1 extrapolate. Does not convert color space.
| Name | Type | Default |
|---|---|---|
amount | float | — |
amountAmount, normally 0…1; not automatically clamped.
ColorNew color retaining the original alpha.
Equals2 overloads
public bool Equals(Color other);Compares all four RGBA components exactly using float ==. For computed values requiring a tolerance use IsEqualApprox.
| Name | Type | Default |
|---|---|---|
other | Color | — |
otherColor to compare.
booltrue when all four components are exactly equal.
public override bool Equals(object? obj);Returns true only when obj is a boxed Color struct with exactly equal RGBA components. Returns false for null or other object types.
| Name | Type | Default |
|---|---|---|
obj | object | — |
objObject to compare; may be null.
boolResult of the type and exact RGBA equality checks.
FromHsvColor
public static Color FromHsv(float hue, float saturation, float value, float alpha = 1f);Creates RGB from HSV. hue is measured in turns, not degrees: 0 is red, 1/3 green and 2/3 blue. When saturation = 0, RGB = (value, value, value). Alpha defaults to 1. Does not clamp saturation, value or alpha.
Supply finite hue in 0…1. Positive turns repeat, but negative hue is not normalized correctly: −0.1 can produce a negative RGB channel, for example. For a color-picker UI using degrees and an explicit S/V/A policy of 0…1:
using System;
using Reckfell;
public static class PaletteColor
{
// UI palette policy: hue in degrees; finite S, V and A in 0..1.
public static bool TryFromHsvDegrees(float degrees, float saturation,
float value, float alpha, out Color color)
{
color = default;
if (!float.IsFinite(degrees) || !InUnitRange(saturation)
|| !InUnitRange(value) || !InUnitRange(alpha)) return false;
float hue = degrees / 360f;
hue -= MathF.Floor(hue);
color = Color.FromHsv(hue, saturation, value, alpha);
return true;
}
private static bool InUnitRange(float value) =>
float.IsFinite(value) && value >= 0f && value <= 1f;
}| Name | Type | Default |
|---|---|---|
hue | float | — |
saturation | float | — |
value | float | — |
alpha | float | 1f |
hueHue in turns; use a finite value in 0…1. Divide degrees by 360 and normalize.
saturationSaturation, normally 0…1; 0 produces gray. Not clamped.
valueHSV maximum RGB component, normally 0…1; may exceed 1 for HDR calculations. This is not Luminance.
alphaUnclamped alpha; defaults to 1.
ColorNew RGB with the supplied alpha; no sRGB/linear conversion.
FromHtmlColor
public static Color FromHtml(ReadOnlySpan<char> rgba);Parses RGB, RGBA, RRGGBB or RRGGBBAA with optional #. Short channels are divided by 15, long channels by 255; omitted alpha is 1. Does not convert color space.
Always validate with HtmlIsValid first. Empty input returns opaque black although it fails validation. Invalid length throws ArgumentOutOfRangeException, but some invalid characters can pass parsing: the current C# SDK accepts 1g0000, for example.
using System;
using Reckfell;
public static class HtmlColorInput
{
// Exact hexadecimal format only: no names, spaces or CSS functions.
public static bool TryParse(ReadOnlySpan<char> text, out Color color)
{
color = default;
if (!Color.HtmlIsValid(text)) return false;
color = Color.FromHtml(text);
return true;
}
}| Name | Type | Default |
|---|---|---|
rgba | ReadOnlySpan<char> | — |
rgbaHex code; call HtmlIsValid first for user input.
ColorParsed RGBA; empty input separately returns (0, 0, 0, 1).
FromOkHslColor
public static Color FromOkHsl(float hue, float saturation, float lightness, float alpha = 1f);Converts OKHSL to sRGB through native engine code. This differs from HSV: read back with OkHslH, OkHslS and OkHslL, not H, S and V. Input coordinates are normally 0…1, with hue in turns. lightness = 0 produces black and 1 white.
Clamps all four output RGBA components to 0…1, including alpha, unlike FromHsv. Call SrgbToLinear() for subsequent linear-light calculations; this constructor is unsuitable for preserving HDR range.
| Name | Type | Default |
|---|---|---|
hue | float | — |
saturation | float | — |
lightness | float | — |
alpha | float | 1f |
hueOKHSL hue in turns; supply a finite value in 0…1.
saturationOKHSL saturation; supply a finite value in 0…1.
lightnessOKHSL lightness, not HSV V; finite value in 0…1.
alphaAlpha, default 1; output is clamped to 0…1.
ColorsRGB color with clamped RGBA components.
FromRgbe9995Color
public static Color FromRgbe9995(uint rgbe);Decodes packed HDR RGBE9995: bits 0…8 are R, 9…17 G, 18…26 B, and 27…31 the shared exponent E. Each RGB result is its 9-bit mantissa * 2^(E − 24). Alpha is always 1: this format has no A channel.
Do not confuse this with Color(uint) 0xRRGGBBAA. RGB values may exceed 1; the method performs no tone mapping or sRGB/linear conversion. Zero produces opaque black.
| Name | Type | Default |
|---|---|---|
rgbe | uint | — |
rgbe32-bit RGBE9995 with a shared exponent, not RGBA8.
ColorDecoded HDR RGB with A = 1.
FromStringColor
public static Color FromString(string str, Color @default);First validates an HTML code with HtmlIsValid; otherwise looks up a normalized Colors name. Returns default unchanged when no color matches. Empty text also returns the fallback. Use for input that permits names; use HtmlIsValid and FromHtml for hex-only input.
| Name | Type | Default |
|---|---|---|
str | string | — |
default | Color | — |
strRGB/RGBA HTML code with 3, 4, 6 or 8 hex digits and optional #, or a Colors name.
defaultFallback color for unrecognized input.
ColorParsed color or the supplied default.
GetHashCodeint
public override int GetHashCode();Computes HashCode.Combine(R, G, B, A). Used with exact Equals, not IsEqualApprox; nearby colors need not have the same hash. Do not persist this value as a stable color ID across runs.
intRGBA hash for the current process.
HtmlIsValidbool
public static bool HtmlIsValid(ReadOnlySpan<char> color);Validates the exact hex format: 3/4/6/8 digits, optional leading #, either letter case. Rejects empty text, spaces, color names and CSS functions. Call before FromHtml for untrusted input: FromHtml alone does not strictly validate every character.
| Name | Type | Default |
|---|---|---|
color | ReadOnlySpan<char> | — |
colorText to validate; no automatic Trim.
booltrue only for the supported hex format.
InvertedColor
public Color Inverted();Returns (1 − R, 1 − G, 1 − B, A). Preserves alpha; unlike this method, unary -color returns 1 − A for alpha. Components are not clamped.
ColorColor with inverted RGB and unchanged alpha.
IsEqualApproxbool
public bool IsEqualApprox(Color other);Compares each RGBA component through Mathf.IsEqualApprox. All four comparisons must pass, including alpha. This is a numeric tolerance, not perceptual similarity; convert colors in different RGB encodings to the same encoding first.
| Name | Type | Default |
|---|---|---|
other | Color | — |
otherColor in the same RGB encoding.
booltrue when every corresponding RGBA component is approximately equal.
LerpColor
public Color Lerp(Color to, float weight);Computes RGBA + (to − RGBA) * weight component by component. At weight = 0 returns the starting color; at 1 returns to; outside 0…1 extrapolates. Interpolates alpha too. Does not composite layers, premultiply RGB or convert sRGB to linear. For a linear-light transition between sRGB colors, apply SrgbToLinear() to both inputs and LinearToSrgb() to the result.
| Name | Type | Default |
|---|---|---|
to | Color | — |
weight | float | — |
toTarget color in the same RGB encoding as the source.
weightFactor, normally 0…1; values outside this range extrapolate.
ColorNew interpolated or extrapolated RGBA.
LightenedColor
public Color Lightened(float amount);Lightens RGB using RGB + (1 − RGB) * amount, preserving A. At amount = 0 the color is unchanged; at 1 RGB becomes white. amount is not clamped: values outside 0…1 extrapolate. Does not convert color space.
| Name | Type | Default |
|---|---|---|
amount | float | — |
amountAmount, normally 0…1; not automatically clamped.
ColorNew color retaining the original alpha.
LinearToSrgbColor
public Color LinearToSrgb();Converts RGB from linear to sRGB using the per-channel sRGB transfer function; preserves A. The caller must know the input encoding: Color stores no encoding tag. Does not clamp HDR values or perform tone mapping. Applying the conversion again to an already converted color produces the wrong result. Leaves the source struct unchanged.
ColorNew color with sRGB RGB and unchanged alpha.
SrgbToLinearColor
public Color SrgbToLinear();Converts RGB from sRGB to linear using the per-channel sRGB transfer function; preserves A. The caller must know the input encoding: Color stores no encoding tag. Does not clamp HDR values or perform tone mapping. Applying the conversion again to an already converted color produces the wrong result. Leaves the source struct unchanged.
ColorNew color with linear RGB and unchanged alpha.
ToAbgr32uint
public uint ToAbgr32();Packs channels into uint 0xAABBGGRR, 8 bits per channel, ordered from high to low bits. Multiplies each channel by 255 and uses Math.Round (midpoints to even). Supply finite values in 0…1; the method does not clamp. For ordinary out-of-range color use Clamp() first; for HDR choose a tone-mapping policy first. Integer format does not specify memory byte order or convert sRGB/linear.
uintUnsigned 0xAABBGGRR value, quantized to 8 bits per channel.
ToAbgr64ulong
public ulong ToAbgr64();Packs channels into ulong 0xAAAABBBBGGGGRRRR, 16 bits per channel, ordered from high to low bits. Multiplies each channel by 65535 and uses Math.Round (midpoints to even). Supply finite values in 0…1; the method does not clamp. For ordinary out-of-range color use Clamp() first; for HDR choose a tone-mapping policy first. Integer format does not specify memory byte order or convert sRGB/linear.
ulongUnsigned 0xAAAABBBBGGGGRRRR value, quantized to 16 bits per channel.
ToArgb32uint
public uint ToArgb32();Packs channels into uint 0xAARRGGBB, 8 bits per channel, ordered from high to low bits. Multiplies each channel by 255 and uses Math.Round (midpoints to even). Supply finite values in 0…1; the method does not clamp. For ordinary out-of-range color use Clamp() first; for HDR choose a tone-mapping policy first. Integer format does not specify memory byte order or convert sRGB/linear.
uintUnsigned 0xAARRGGBB value, quantized to 8 bits per channel.
ToArgb64ulong
public ulong ToArgb64();Packs channels into ulong 0xAAAARRRRGGGGBBBB, 16 bits per channel, ordered from high to low bits. Multiplies each channel by 65535 and uses Math.Round (midpoints to even). Supply finite values in 0…1; the method does not clamp. For ordinary out-of-range color use Clamp() first; for HDR choose a tone-mapping policy first. Integer format does not specify memory byte order or convert sRGB/linear.
ulongUnsigned 0xAAAARRRRGGGGBBBB value, quantized to 16 bits per channel.
ToHsvvoid
public void ToHsv(out float hue, out float saturation, out float value);Computes HSV from current RGB into three out parameters; does not modify the color or output alpha. For ordinary RGB in 0…1, hue and saturation are also in 0…1. Gray has hue = 0 and saturation = 0; black also has value = 0. HDR value may exceed 1. Uses stored RGB without sRGB/linear conversion.
| Name | Type | Default |
|---|---|---|
hue | float | — |
saturation | float | — |
value | float | — |
hueOutput hue in turns; 0 for gray.
saturationOutput saturation; 0 for black.
valueOutput max(R, G, B), not relative luminance.
ToHtmlstring
public string ToHtml(bool includeAlpha = true);Returns lowercase hex without #: RRGGBBAA by default, or RRGGBB when includeAlpha = false. Finite channel values are clamped to 0…1 and rounded to bytes. For example, new Color(1, 1, 1, 0.5f).ToHtml() yields "ffffff80". Quantizes to 8 bits per channel without converting color space.
| Name | Type | Default |
|---|---|---|
includeAlpha | bool | true |
includeAlphatrue: append AA; false: return RGB only.
string6 or 8 hex digits without #.
ToRgba32uint
public uint ToRgba32();Packs channels into uint 0xRRGGBBAA, 8 bits per channel, ordered from high to low bits. Multiplies each channel by 255 and uses Math.Round (midpoints to even). Supply finite values in 0…1; the method does not clamp. For ordinary out-of-range color use Clamp() first; for HDR choose a tone-mapping policy first. Integer format does not specify memory byte order or convert sRGB/linear.
uintUnsigned 0xRRGGBBAA value, quantized to 8 bits per channel.
ToRgba64ulong
public ulong ToRgba64();Packs channels into ulong 0xRRRRGGGGBBBBAAAA, 16 bits per channel, ordered from high to low bits. Multiplies each channel by 65535 and uses Math.Round (midpoints to even). Supply finite values in 0…1; the method does not clamp. For ordinary out-of-range color use Clamp() first; for HDR choose a tone-mapping policy first. Integer format does not specify memory byte order or convert sRGB/linear.
ulongUnsigned 0xRRRRGGGGBBBBAAAA value, quantized to 16 bits per channel.
ToString2 overloads
public override string ToString();Returns (R, G, B, A) text using CultureInfo.InvariantCulture: the decimal point does not depend on system language. The parameterless overload uses the default numeric format. Use ToHtml(), not ToString(), for an HTML code.
stringDiagnostic RGBA text representation.
public string ToString(string? format);Returns (R, G, B, A) text using CultureInfo.InvariantCulture: the decimal point does not depend on system language. Passes format to each float component; F2 produces two decimal places, for example. Use ToHtml(), not ToString(), for an HTML code.
| Name | Type | Default |
|---|---|---|
format | string | — |
formatfloat numeric format, such as F2; null uses the default format.
stringDiagnostic RGBA text representation.
op_AdditionColor
public static Color operator +(Color left, Color right);Applies + to each RGBA component with the corresponding component of the other color. Includes alpha. Does not clamp channels or convert color space. This is channel arithmetic; use Blend to composite transparent layers.
| Name | Type | Default |
|---|---|---|
left | Color | — |
right | Color | — |
leftColor operand; all RGBA components are used.
rightColor operand; all RGBA components are used.
ColorNew result of component-wise arithmetic.
op_Division2 overloads
public static Color operator /(Color left, Color right);Applies / to each RGBA component with the corresponding component of the other color. Includes alpha. Does not clamp channels or convert color space. A zero float divisor can produce Infinity or NaN; validate divisors first.
| Name | Type | Default |
|---|---|---|
left | Color | — |
right | Color | — |
leftColor operand; all RGBA components are used.
rightColor operand; all RGBA components are used.
ColorNew result of component-wise arithmetic.
public static Color operator /(Color color, float scale);Applies / to each RGBA component with one scale. Includes alpha. Does not clamp channels or convert color space. A zero float divisor can produce Infinity or NaN; validate divisors first.
| Name | Type | Default |
|---|---|---|
color | Color | — |
scale | float | — |
colorColor operand; all RGBA components are used.
scaleDivisor for all RGBA components; require a nonzero value.
ColorNew result of component-wise arithmetic.
op_Equalitybool
public static bool operator ==(Color left, Color right);Exact comparison of all four float RGBA components using ==. Computations may introduce rounding error; use IsEqualApprox for approximate comparison. Does not compare visible results after compositing onto a background.
| Name | Type | Default |
|---|---|---|
left | Color | — |
right | Color | — |
leftRGBA operand to compare.
rightRGBA operand to compare.
boolResult of the exact comparison.
op_GreaterThanbool
public static bool operator >(Color left, Color right);Lexicographically compares finite RGBA using >: R first, then G on equality, then B and A. This provides a sorting order, not a brightness or opacity comparison. Do not use NaN components for ordering.
| Name | Type | Default |
|---|---|---|
left | Color | — |
right | Color | — |
leftFinite RGBA operand to compare.
rightFinite RGBA operand to compare.
boolResult of the lexicographic comparison.
op_GreaterThanOrEqualbool
public static bool operator >=(Color left, Color right);Lexicographically compares finite RGBA using >=: R first, then G on equality, then B and A. This provides a sorting order, not a brightness or opacity comparison. Do not use NaN components for ordering.
| Name | Type | Default |
|---|---|---|
left | Color | — |
right | Color | — |
leftFinite RGBA operand to compare.
rightFinite RGBA operand to compare.
boolResult of the lexicographic comparison.
op_Inequalitybool
public static bool operator !=(Color left, Color right);Exact comparison of all four float RGBA components using !=. Computations may introduce rounding error; use IsEqualApprox for approximate comparison. Does not compare visible results after compositing onto a background.
| Name | Type | Default |
|---|---|---|
left | Color | — |
right | Color | — |
leftRGBA operand to compare.
rightRGBA operand to compare.
boolResult of the exact comparison.
op_LessThanbool
public static bool operator <(Color left, Color right);Lexicographically compares finite RGBA using <: R first, then G on equality, then B and A. This provides a sorting order, not a brightness or opacity comparison. Do not use NaN components for ordering.
| Name | Type | Default |
|---|---|---|
left | Color | — |
right | Color | — |
leftFinite RGBA operand to compare.
rightFinite RGBA operand to compare.
boolResult of the lexicographic comparison.
op_LessThanOrEqualbool
public static bool operator <=(Color left, Color right);Lexicographically compares finite RGBA using <=: R first, then G on equality, then B and A. This provides a sorting order, not a brightness or opacity comparison. Do not use NaN components for ordering.
| Name | Type | Default |
|---|---|---|
left | Color | — |
right | Color | — |
leftFinite RGBA operand to compare.
rightFinite RGBA operand to compare.
boolResult of the lexicographic comparison.
op_Multiply3 overloads
public static Color operator *(Color left, Color right);Applies * to each RGBA component with the corresponding component of the other color. Includes alpha. Does not clamp channels or convert color space. This is channel arithmetic; use Blend to composite transparent layers.
| Name | Type | Default |
|---|---|---|
left | Color | — |
right | Color | — |
leftColor operand; all RGBA components are used.
rightColor operand; all RGBA components are used.
ColorNew result of component-wise arithmetic.
public static Color operator *(Color color, float scale);Applies * to each RGBA component with one scale. Includes alpha. Does not clamp channels or convert color space. This is channel arithmetic; use Blend to composite transparent layers.
| Name | Type | Default |
|---|---|---|
color | Color | — |
scale | float | — |
colorColor operand; all RGBA components are used.
scaleMultiplier for all RGBA components.
ColorNew result of component-wise arithmetic.
public static Color operator *(float scale, Color color);Applies * to each RGBA component with one scale. Includes alpha. Does not clamp channels or convert color space. This is channel arithmetic; use Blend to composite transparent layers.
| Name | Type | Default |
|---|---|---|
scale | float | — |
color | Color | — |
scaleMultiplier for all RGBA components.
colorColor operand; all RGBA components are used.
ColorNew result of component-wise arithmetic.
op_SubtractionColor
public static Color operator -(Color left, Color right);Applies − to each RGBA component with the corresponding component of the other color. Includes alpha. Does not clamp channels or convert color space. This is channel arithmetic; use Blend to composite transparent layers.
| Name | Type | Default |
|---|---|---|
left | Color | — |
right | Color | — |
leftColor operand; all RGBA components are used.
rightColor operand; all RGBA components are used.
ColorNew result of component-wise arithmetic.
op_UnaryNegationColor
public static Color operator -(Color color);Returns (1 − R, 1 − G, 1 − B, 1 − A). This inverts relative to white, rather than arithmetically negating the components. Also inverts alpha. Use Inverted() to preserve alpha.
| Name | Type | Default |
|---|---|---|
color | Color | — |
colorInput RGBA.
ColorColor with all four components inverted.
op_UnaryPlusColor
public static Color operator +(Color color);Returns the color unchanged; does not clamp components.
| Name | Type | Default |
|---|---|---|
color | Color | — |
colorInput RGBA.
ColorThe same RGBA.
Fields and constants4
AField
public float A;Alpha as an unclamped float; normally 0 means transparent and 1 opaque. Actual effect depends on the material and blend mode. Changing A does not itself multiply RGB by alpha.
BField
public float B;B component as an unclamped float. Usually 0…1; values above 1 can represent HDR calculations. The struct does not tag the channel as sRGB or linear; consuming code determines that.
GField
public float G;G component as an unclamped float. Usually 0…1; values above 1 can represent HDR calculations. The struct does not tag the channel as sRGB or linear; consuming code determines that.
RField
public float R;R component as an unclamped float. Usually 0…1; values above 1 can represent HDR calculations. The struct does not tag the channel as sRGB or linear; consuming code determines that.