The Color struct represents a color using four floating-point values (red, green, blue, and alpha) each ranging from 0 to 1. This struct provides various methods and properties to manipulate and retrieve color information.
The Color struct represents a color using four floating-point values (red, green, blue, and alpha) each ranging from 0 to 1. This struct provides various methods and properties to manipulate and retrieve color information.
Member Name | Summary |
---|---|
Min | Returns the minimum color by comparing two colors. |
Max | Returns the maximum color by comparing two colors. |
Average | Calculates the average color from an array of colors. |
Lerp | Linearly interpolates between two colors. |
FromBytes | Creates a color from byte values for red, green, blue, and alpha. |
FromRgb | Creates a color from a 32-bit RGB value. |
FromRgba | Creates a color from a 32-bit RGBA value. |
Parse | Parses a string to create a color, if possible. |
TryParse | Attempts to parse a string to create a color, returning a boolean indicating success. |
Random | Returns a random color from a set of preset colors. |
Member Name | Summary |
---|---|
WithAlpha | Returns a new color with the specified alpha value. |
WithAlphaMultiplied | Returns a new color with the alpha value multiplied by a given factor. |
WithRed | Returns a new color with the specified red value. |
WithGreen | Returns a new color with the specified green value. |
WithBlue | Returns a new color with the specified blue value. |
ToHsv | Converts this color to HSV format. |
ToColor32 | Converts this color to a 32-bit color, optionally using sRGB. |
LerpTo | Interpolates this color towards a target color. |
AdjustHue | Adjusts the hue of this color by a specified amount. |
Darken | Darkens this color by a specified fraction. |
Lighten | Lightens this color by a specified fraction. |
Invert | Returns the inverted color, keeping alpha unchanged. |
Desaturate | Desaturates this color by a specified fraction. |
Saturate | Saturates this color by a specified fraction. |
ComponentCountChangedBetweenColors | Determines the component count change between two colors. |
Property Name | Summary |
---|---|
Luminance | Returns the luminance of the color, essentially its grayscale value. |
IsRepresentableInHex | Indicates if the color can be represented in hexadecimal format. |
IsSdr | Indicates if all components are within the 0 to 1 range. |
IsHdr | Indicates if any component exceeds 1. |
Hex | String representation of the color in "#RRGGBB[AA]" format. |
Rgba | String representation in CSS rgba function notation. |
Rgb | String representation in CSS rgb function notation. |
RgbaInt | Integer representation of the color in 0xRRGGBBAA format. |
RgbInt | Integer representation of the color in 0xRRGGBB format. |
RawInt | Integer representation of the color in 0xAABBGGRR format. |
Item | Accesses the color components by index. |
Field Name | Summary |
---|---|
r | The red color component, which can exceed the 0-1 range. |
g | The green color component, which can exceed the 0-1 range. |
b | The blue color component, which can exceed the 0-1 range. |
a | The alpha component, representing transparency, which can exceed the 0-1 range. |
White | Fully opaque white color. |
Gray | Fully opaque gray color, midway between white and black. |
Black | Fully opaque black color. |
Red | Fully opaque pure red color. |
Green | Fully opaque pure green color. |
Blue | Fully opaque pure blue color. |
Yellow | Fully opaque yellow color. |
Orange | Fully opaque orange color. |
Cyan | Fully opaque cyan color. |
Magenta | Fully opaque magenta color. |
Transparent | Fully transparent color. |