Table of Contents

Struct Color

Namespace
Gloam.Core.Primitives
Assembly
Gloam.Core.dll

Represents a color with red, green, blue, and alpha components (RGBA format)

public readonly record struct Color : IEquatable<Color>
Implements
Inherited Members

Constructors

Color(int, int, int, int)

Initializes a new Color with the specified RGBA components

public Color(int r, int g, int b, int a = 255)

Parameters

r int

Red component (0-255, will be clamped)

g int

Green component (0-255, will be clamped)

b int

Blue component (0-255, will be clamped)

a int

Alpha component (0-255, will be clamped). Defaults to 255 (fully opaque)

Properties

A

Gets the alpha (opacity) component (0-255, where 255 is fully opaque)

public int A { get; }

Property Value

int

B

Gets the blue component (0-255)

public int B { get; }

Property Value

int

G

Gets the green component (0-255)

public int G { get; }

Property Value

int

R

Gets the red component (0-255)

public int R { get; }

Property Value

int

Methods

FromHex(string)

Creates a Color from a hexadecimal string representation

public static Color FromHex(string hex)

Parameters

hex string

Hexadecimal color string (e.g., "#FF0000" or "FF0000" for red, optionally with alpha)

Returns

Color

A Color representing the hexadecimal value

Exceptions

ArgumentException

Thrown when hex string is invalid