struct Color

robot_2Generated
code_blocksInput

Description

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.

Members

Static Members

Member NameSummary
MinReturns the minimum color by comparing two colors.
MaxReturns the maximum color by comparing two colors.
AverageCalculates the average color from an array of colors.
LerpLinearly interpolates between two colors.
FromBytesCreates a color from byte values for red, green, blue, and alpha.
FromRgbCreates a color from a 32-bit RGB value.
FromRgbaCreates a color from a 32-bit RGBA value.
ParseParses a string to create a color, if possible.
TryParseAttempts to parse a string to create a color, returning a boolean indicating success.
RandomReturns a random color from a set of preset colors.

Instance Members

Member NameSummary
WithAlphaReturns a new color with the specified alpha value.
WithAlphaMultipliedReturns a new color with the alpha value multiplied by a given factor.
WithRedReturns a new color with the specified red value.
WithGreenReturns a new color with the specified green value.
WithBlueReturns a new color with the specified blue value.
ToHsvConverts this color to HSV format.
ToColor32Converts this color to a 32-bit color, optionally using sRGB.
LerpToInterpolates this color towards a target color.
AdjustHueAdjusts the hue of this color by a specified amount.
DarkenDarkens this color by a specified fraction.
LightenLightens this color by a specified fraction.
InvertReturns the inverted color, keeping alpha unchanged.
DesaturateDesaturates this color by a specified fraction.
SaturateSaturates this color by a specified fraction.
ComponentCountChangedBetweenColorsDetermines the component count change between two colors.

Properties

Property NameSummary
LuminanceReturns the luminance of the color, essentially its grayscale value.
IsRepresentableInHexIndicates if the color can be represented in hexadecimal format.
IsSdrIndicates if all components are within the 0 to 1 range.
IsHdrIndicates if any component exceeds 1.
HexString representation of the color in "#RRGGBB[AA]" format.
RgbaString representation in CSS rgba function notation.
RgbString representation in CSS rgb function notation.
RgbaIntInteger representation of the color in 0xRRGGBBAA format.
RgbIntInteger representation of the color in 0xRRGGBB format.
RawIntInteger representation of the color in 0xAABBGGRR format.
ItemAccesses the color components by index.

Fields

Field NameSummary
rThe red color component, which can exceed the 0-1 range.
gThe green color component, which can exceed the 0-1 range.
bThe blue color component, which can exceed the 0-1 range.
aThe alpha component, representing transparency, which can exceed the 0-1 range.
WhiteFully opaque white color.
GrayFully opaque gray color, midway between white and black.
BlackFully opaque black color.
RedFully opaque pure red color.
GreenFully opaque pure green color.
BlueFully opaque pure blue color.
YellowFully opaque yellow color.
OrangeFully opaque orange color.
CyanFully opaque cyan color.
MagentaFully opaque magenta color.
TransparentFully transparent color.