Summary

Represents a color using 4 floats (rgba), with 0-1 range.

Constructors

Color Initialize a color with each component set to given values, in range [0,1]

Fields

a The alpha/transparency color component, in range of 0 (fully transparent) to 1 (fully opaque), which <b>can be exceeded</b>.
b The blue color component, in range of 0-1, which <b>can be exceeded</b>.
g The green color component, in range of 0-1, which <b>can be exceeded</b>.
r The red color component, in range of 0-1, which <b>can be exceeded</b>.

Properties

Hex String representation of the form "#RRGGBB[AA]".
IsHdr Returns true if any component exceeds 1
IsRepresentableInHex Returns true if this color can be represented in hexadecimal format (#RRGGBB[AA]). This may not be the case if the color components are outside of [0,1] range.
IsSdr Returns true if all components are between 0 and 1
Item
Luminance Returns the luminance of the color, basically it's grayscale value or "black and white version".
RawInt Integer representation of the form 0xAABBGGRR as used by native code.
Rgb String representation in the form of <see href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb">rgb</see>( r, g, b ) css function notation.
Rgba String representation in the form of <see href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgba">rgba</see>( r, g, b, a ) css function notation.
RgbaInt Integer representation of the form 0xRRGGBBAA.
RgbInt Integer representation of the form 0xRRGGBB.

Methods

AdjustHue Increases or decreases this color's hue
ComponentCountChangedBetweenColors Returns how many color components would be changed between this color and another color
Darken Darkens the color by given amount.
Desaturate Desaturates the color by given amount.
Invert Returns inverted color. Alpha is unchanged.
LerpTo Performs linear interpolation between this and given colors.
Lighten Lightens the color by given amount.
Saturate Saturates the color by given amount.
ToColor32 Convert to a Color32 (a 32 bit color value)
ToHsv Converts this color to a HSV format.
WithAlpha Returns this color with its alpha value changed
WithAlphaMultiplied Similar to Color.WithAlpha(System.Single) but multiplies the alpha instead of replacing.
WithBlue Returns this color with its blue value changed
WithColorMultiplied Returns a new version with only the red, green, blue components multiplied
WithGreen Returns this color with its green value changed
WithRed Returns this color with its red value changed

Static Fields

Black Fully opaque black color.
Blue Fully opaque pure blue color.
Cyan Fully opaque cyan color.
Gray Fully opaque gray color, right between white and black.
Green Fully opaque pure green color.
Magenta Fully opaque magenta color.
Orange Fully opaque orange color.
Red Fully opaque pure red color.
Transparent Fully transparent color.
White Fully opaque white color.
Yellow Fully opaque yellow color.

Static Properties

Random Returns a random color out of 8 preset colors.

Static Methods

Average Returns a color whose components are averaged of all given colors.
FromBytes Creates a color from 0-255 range inputs, converting them to 0-1 range.
FromRgb Converts an integer of the form 0xRRGGBB into the color #RRGGBB with 100% alpha.
FromRgba Converts an integer of the form 0xRRGGBBAA into the color #RRGGBBAA.
Lerp Performs linear interpolation between two colors.
Max Returns a new color with each component being the maximum of the 2 given colors.
Min Returns a new color with each component being the minimum of the 2 given colors.
Parse Parse the color from a string. Many common formats are supported.
TryParse Try to parse the color. Returns true on success
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.