Skip to content

Color

public struct Color

An RGBA colour of four float channels, each normally 0 to 1; the struct does not clamp them. A light’s colour, a material’s albedo or emission, a colour property, a shader colour uniform and an image sensor’s pixel all use it.

public Color(float r, float g, float b, float a = 1f);

Creates a colour from red, green, blue and alpha channels, each normally 0 to 1. Alpha defaults to 1, fully opaque.

public float R { get; set; }

The red channel, normally 0 to 1.

public float G { get; set; }

The green channel, normally 0 to 1.

public float B { get; set; }

The blue channel, normally 0 to 1.

public float A { get; set; }

The alpha (opacity) channel, normally 0 to 1: 1 is fully opaque and 0 fully transparent, where the thing being coloured uses alpha.

static

public static Color White { get; }

Opaque white, (1, 1, 1, 1).

static

public static Color Black { get; }

Opaque black, (0, 0, 0, 1).

static

public static Color Transparent { get; }

Fully transparent black, (0, 0, 0, 0).

static

public static Color Lerp(Color from, Color to, float weight);

Blends from from to to channel by channel, alpha included: a weight of 0 gives from and 1 gives to. The weight is not clamped, so values outside 0 to 1 carry on past either colour and can push channels outside 0 to 1.

override

public override bool Equals(object obj);

True when obj is a Color with exactly equal channels.

override

public override int GetHashCode();

A hash of the channels, so the colour can key a dictionary or a set.

override

public override string ToString();

The colour as text, for example Color(1, 0.5, 0, 1).

static

public static bool operator ==(Color a, Color b);

True when all four channels are exactly equal.

static

public static bool operator !=(Color a, Color b);

True when any channel differs, compared exactly.

Generated from the CRUMB source, commit fcec660d, 2026-10-29.