reckfellENGINE

Color

Float RGBA components; alpha and color encoding depend on how the value is used.

On this page
struct ColorReckfellSharpInherits ValueType

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
# Color · 1/6
C#
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.

Parameters
NameTypeDefault
cColor—
afloat1f
c

RGB source; its alpha is ignored.

a

Unclamped alpha; normally 0…1. Defaults to 1.

# Color · 2/6
C#
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.

Parameters
NameTypeDefault
rfloat—
gfloat—
bfloat—
afloat1f
r

Unclamped R component; normally 0…1.

g

Unclamped G component; normally 0…1.

b

Unclamped B component; normally 0…1.

a

Unclamped alpha; normally 0…1. Defaults to 1.

# Color · 3/6
C#
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.

Parameters
NameTypeDefault
codestring—
code

RGB/RGBA HTML code with 3, 4, 6 or 8 hex digits and optional #, or a Colors name.

# Color · 4/6
C#
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.

Parameters
NameTypeDefault
codestring—
alphafloat—
code

RGB/RGBA HTML code with 3, 4, 6 or 8 hex digits and optional #, or a Colors name.

alpha

New alpha replacing the value from code; normally 0…1.

# Color · 5/6
C#
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.

Parameters
NameTypeDefault
rgbauint—
rgba

Unsigned 0xRRGGBBAA value.

# Color · 6/6
C#
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.

Parameters
NameTypeDefault
rgbaulong—
rgba

Unsigned 0xRRRRGGGGBBBBAAAA value.

Properties12

A8Property
# A8
C#
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
# B8
C#
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
# G8
C#
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
# H
C#
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
# Item
C#
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
# Luminance
C#
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
# OkHslH
C#
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
# OkHslL
C#
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
# OkHslS
C#
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
# R8
C#
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
# S
C#
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
# V
C#
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
# Blend
C#
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:

C#
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();
    }
}
Parameters
NameTypeDefault
overColor—
over

Foreground with straight alpha; this color is the background.

Returns Color

New straight-alpha color; input colors remain unchanged.

ClampColor
# Clamp
C#
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.

Parameters
NameTypeDefault
minColor?default
maxColor?default
min

Lower RGBA bounds; null means four zeros.

max

Upper RGBA bounds; null means four ones.

Returns Color

Copy with clamped channels.

Color8Color
# Color8
C#
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.

Parameters
NameTypeDefault
r8byte—
g8byte—
b8byte—
a8byte255
r8

R channel, integer 0…255.

g8

G channel, integer 0…255.

b8

B channel, integer 0…255.

a8

A channel, integer 0…255. Defaults to 255.

Returns Color

Color with channels in 0…1.

DarkenedColor
# Darkened
C#
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.

Parameters
NameTypeDefault
amountfloat—
amount

Amount, normally 0…1; not automatically clamped.

Returns Color

New color retaining the original alpha.

Equals2 overloads
# Equals · 1/2
C#
public bool Equals(Color other);

Compares all four RGBA components exactly using float ==. For computed values requiring a tolerance use IsEqualApprox.

Parameters
NameTypeDefault
otherColor—
other

Color to compare.

Returns bool

true when all four components are exactly equal.

# Equals · 2/2
C#
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.

Parameters
NameTypeDefault
objobject—
obj

Object to compare; may be null.

Returns bool

Result of the type and exact RGBA equality checks.

FromHsvColor
# FromHsv
C#
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:

C#
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;
}
Parameters
NameTypeDefault
huefloat—
saturationfloat—
valuefloat—
alphafloat1f
hue

Hue in turns; use a finite value in 0…1. Divide degrees by 360 and normalize.

saturation

Saturation, normally 0…1; 0 produces gray. Not clamped.

value

HSV maximum RGB component, normally 0…1; may exceed 1 for HDR calculations. This is not Luminance.

alpha

Unclamped alpha; defaults to 1.

Returns Color

New RGB with the supplied alpha; no sRGB/linear conversion.

FromHtmlColor
# FromHtml
C#
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.

C#
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;
    }
}
Parameters
NameTypeDefault
rgbaReadOnlySpan<char>—
rgba

Hex code; call HtmlIsValid first for user input.

Returns Color

Parsed RGBA; empty input separately returns (0, 0, 0, 1).

FromOkHslColor
# FromOkHsl
C#
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.

Parameters
NameTypeDefault
huefloat—
saturationfloat—
lightnessfloat—
alphafloat1f
hue

OKHSL hue in turns; supply a finite value in 0…1.

saturation

OKHSL saturation; supply a finite value in 0…1.

lightness

OKHSL lightness, not HSV V; finite value in 0…1.

alpha

Alpha, default 1; output is clamped to 0…1.

Returns Color

sRGB color with clamped RGBA components.

FromRgbe9995Color
# FromRgbe9995
C#
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.

Parameters
NameTypeDefault
rgbeuint—
rgbe

32-bit RGBE9995 with a shared exponent, not RGBA8.

Returns Color

Decoded HDR RGB with A = 1.

FromStringColor
# FromString
C#
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.

Parameters
NameTypeDefault
strstring—
defaultColor—
str

RGB/RGBA HTML code with 3, 4, 6 or 8 hex digits and optional #, or a Colors name.

default

Fallback color for unrecognized input.

Returns Color

Parsed color or the supplied default.

GetHashCodeint
# GetHashCode
C#
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.

Returns int

RGBA hash for the current process.

HtmlIsValidbool
# HtmlIsValid
C#
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.

Parameters
NameTypeDefault
colorReadOnlySpan<char>—
color

Text to validate; no automatic Trim.

Returns bool

true only for the supported hex format.

InvertedColor
# Inverted
C#
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.

Returns Color

Color with inverted RGB and unchanged alpha.

IsEqualApproxbool
# IsEqualApprox
C#
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.

Parameters
NameTypeDefault
otherColor—
other

Color in the same RGB encoding.

Returns bool

true when every corresponding RGBA component is approximately equal.

LerpColor
# Lerp
C#
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.

Parameters
NameTypeDefault
toColor—
weightfloat—
to

Target color in the same RGB encoding as the source.

weight

Factor, normally 0…1; values outside this range extrapolate.

Returns Color

New interpolated or extrapolated RGBA.

LightenedColor
# Lightened
C#
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.

Parameters
NameTypeDefault
amountfloat—
amount

Amount, normally 0…1; not automatically clamped.

Returns Color

New color retaining the original alpha.

LinearToSrgbColor
# LinearToSrgb
C#
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.

Returns Color

New color with sRGB RGB and unchanged alpha.

SrgbToLinearColor
# SrgbToLinear
C#
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.

Returns Color

New color with linear RGB and unchanged alpha.

ToAbgr32uint
# ToAbgr32
C#
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.

Returns uint

Unsigned 0xAABBGGRR value, quantized to 8 bits per channel.

ToAbgr64ulong
# ToAbgr64
C#
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.

Returns ulong

Unsigned 0xAAAABBBBGGGGRRRR value, quantized to 16 bits per channel.

ToArgb32uint
# ToArgb32
C#
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.

Returns uint

Unsigned 0xAARRGGBB value, quantized to 8 bits per channel.

ToArgb64ulong
# ToArgb64
C#
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.

Returns ulong

Unsigned 0xAAAARRRRGGGGBBBB value, quantized to 16 bits per channel.

ToHsvvoid
# ToHsv
C#
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.

Parameters
NameTypeDefault
huefloat—
saturationfloat—
valuefloat—
hue

Output hue in turns; 0 for gray.

saturation

Output saturation; 0 for black.

value

Output max(R, G, B), not relative luminance.

ToHtmlstring
# ToHtml
C#
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.

Parameters
NameTypeDefault
includeAlphabooltrue
includeAlpha

true: append AA; false: return RGB only.

Returns string

6 or 8 hex digits without #.

ToRgba32uint
# ToRgba32
C#
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.

Returns uint

Unsigned 0xRRGGBBAA value, quantized to 8 bits per channel.

ToRgba64ulong
# ToRgba64
C#
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.

Returns ulong

Unsigned 0xRRRRGGGGBBBBAAAA value, quantized to 16 bits per channel.

ToString2 overloads
# ToString · 1/2
C#
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.

Returns string

Diagnostic RGBA text representation.

# ToString · 2/2
C#
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.

Parameters
NameTypeDefault
formatstring—
format

float numeric format, such as F2; null uses the default format.

Returns string

Diagnostic RGBA text representation.

op_AdditionColor
# op_Addition
C#
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.

Parameters
NameTypeDefault
leftColor—
rightColor—
left

Color operand; all RGBA components are used.

right

Color operand; all RGBA components are used.

Returns Color

New result of component-wise arithmetic.

op_Division2 overloads
# op_Division · 1/2
C#
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.

Parameters
NameTypeDefault
leftColor—
rightColor—
left

Color operand; all RGBA components are used.

right

Color operand; all RGBA components are used.

Returns Color

New result of component-wise arithmetic.

# op_Division · 2/2
C#
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.

Parameters
NameTypeDefault
colorColor—
scalefloat—
color

Color operand; all RGBA components are used.

scale

Divisor for all RGBA components; require a nonzero value.

Returns Color

New result of component-wise arithmetic.

op_Equalitybool
# op_Equality
C#
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.

Parameters
NameTypeDefault
leftColor—
rightColor—
left

RGBA operand to compare.

right

RGBA operand to compare.

Returns bool

Result of the exact comparison.

op_GreaterThanbool
# op_GreaterThan
C#
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.

Parameters
NameTypeDefault
leftColor—
rightColor—
left

Finite RGBA operand to compare.

right

Finite RGBA operand to compare.

Returns bool

Result of the lexicographic comparison.

op_GreaterThanOrEqualbool
# op_GreaterThanOrEqual
C#
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.

Parameters
NameTypeDefault
leftColor—
rightColor—
left

Finite RGBA operand to compare.

right

Finite RGBA operand to compare.

Returns bool

Result of the lexicographic comparison.

op_Inequalitybool
# op_Inequality
C#
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.

Parameters
NameTypeDefault
leftColor—
rightColor—
left

RGBA operand to compare.

right

RGBA operand to compare.

Returns bool

Result of the exact comparison.

op_LessThanbool
# op_LessThan
C#
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.

Parameters
NameTypeDefault
leftColor—
rightColor—
left

Finite RGBA operand to compare.

right

Finite RGBA operand to compare.

Returns bool

Result of the lexicographic comparison.

op_LessThanOrEqualbool
# op_LessThanOrEqual
C#
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.

Parameters
NameTypeDefault
leftColor—
rightColor—
left

Finite RGBA operand to compare.

right

Finite RGBA operand to compare.

Returns bool

Result of the lexicographic comparison.

op_Multiply3 overloads
# op_Multiply · 1/3
C#
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.

Parameters
NameTypeDefault
leftColor—
rightColor—
left

Color operand; all RGBA components are used.

right

Color operand; all RGBA components are used.

Returns Color

New result of component-wise arithmetic.

# op_Multiply · 2/3
C#
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.

Parameters
NameTypeDefault
colorColor—
scalefloat—
color

Color operand; all RGBA components are used.

scale

Multiplier for all RGBA components.

Returns Color

New result of component-wise arithmetic.

# op_Multiply · 3/3
C#
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.

Parameters
NameTypeDefault
scalefloat—
colorColor—
scale

Multiplier for all RGBA components.

color

Color operand; all RGBA components are used.

Returns Color

New result of component-wise arithmetic.

op_SubtractionColor
# op_Subtraction
C#
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.

Parameters
NameTypeDefault
leftColor—
rightColor—
left

Color operand; all RGBA components are used.

right

Color operand; all RGBA components are used.

Returns Color

New result of component-wise arithmetic.

op_UnaryNegationColor
# op_UnaryNegation
C#
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.

Parameters
NameTypeDefault
colorColor—
color

Input RGBA.

Returns Color

Color with all four components inverted.

op_UnaryPlusColor
# op_UnaryPlus
C#
public static Color operator +(Color color);

Returns the color unchanged; does not clamp components.

Parameters
NameTypeDefault
colorColor—
color

Input RGBA.

Returns Color

The same RGBA.

Fields and constants4

AField
# A
C#
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
# B
C#
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
# G
C#
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
# R
C#
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.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.