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
intRed component (0-255, will be clamped)
g
intGreen component (0-255, will be clamped)
b
intBlue component (0-255, will be clamped)
a
intAlpha 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
B
Gets the blue component (0-255)
public int B { get; }
Property Value
G
Gets the green component (0-255)
public int G { get; }
Property Value
R
Gets the red component (0-255)
public int R { get; }
Property Value
Methods
FromHex(string)
Creates a Color from a hexadecimal string representation
public static Color FromHex(string hex)
Parameters
hex
stringHexadecimal 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