struct Color
in global
Represents a color using 4 floats (rgba), with 0-1 range.
public float r
The red color component, in range of 0-1, which can be exceeded.
public float g
The green color component, in range of 0-1, which can be exceeded.
public float b
The blue color component, in range of 0-1, which can be exceeded.
public float a
The alpha/transparency color component, in range of 0 (fully transparent) to 1 (fully opaque), which can be exceeded.
public Color( float r, float g, float b, float a = 1 )
Initialize a color with each component set to given values, in range [0,1]
public Color( ref float rgb, ref float a )
Initialize a color with the same value for each color, but a different value for alpha
public Color( float all )
Initialize a color with each component set to given value, even alpha.
allA number in range [0-1]
public Color( uint raw )
Initialize from an integer of the form 0xAABBGGRR.
rawPacked integer of the form 0xAABBGGRR.
public Color( int raw )
Initialize from an integer of the form 0xAABBGGRR.
rawPacked integer of the form 0xAABBGGRR.
public Color WithAlpha( float alpha )
Returns this color with its alpha value changed
alphaThe required alpha value, usually between 0-1
public Color WithAlphaMultiplied( float alpha )
Similar to but multiplies the alpha instead of replacing.
public Color WithRed( float red )
Returns this color with its red value changed
public Color WithGreen( float green )
Returns this color with its green value changed
public Color WithBlue( float blue )
Returns this color with its blue value changed
public Color32 ToColor32( bool srgb = False )
Convert to a Color32 (a 32 bit color value)
srgbIf true we'll convert to the srgb color space
public static Color Min( ref Color a, ref Color b )
Returns a new color with each component being the minimum of the 2 given colors.
aColor AbColor B- Returns The new color with minimum values.
public static Color Max( ref Color a, ref Color b )
Returns a new color with each component being the maximum of the 2 given colors.
aColor AbColor B- Returns The new color with maximum values.
public float Luminance { get; }
Returns the luminance of the color, basically it's grayscale value or "black and white version".
public bool IsRepresentableInHex { get; }
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.
public bool IsSdr { get; }
Returns true if all components are between 0 and 1
public bool IsHdr { get; }
Returns true if any component exceeds 1
public static Color White
Fully opaque white color.
public static Color Gray
Fully opaque gray color, right between white and black.
public static Color Black
Fully opaque black color.
public static Color Red
Fully opaque pure red color.
public static Color Green
Fully opaque pure green color.
public static Color Blue
Fully opaque pure blue color.
public static Color Yellow
Fully opaque yellow color.
public static Color Orange
Fully opaque orange color.
public static Color Cyan
Fully opaque cyan color.
public static Color Magenta
Fully opaque magenta color.
public static Color Transparent
Fully transparent color.
public string Hex { get; }
String representation of the form "#RRGGBB[AA]".
public string Rgba { get; }
String representation in the form of rgba( r, g, b, a ) css function notation.
public string Rgb { get; }
String representation in the form of rgb( r, g, b ) css function notation.
public uint RgbaInt { get; }
Integer representation of the form 0xRRGGBBAA.
public uint RgbInt { get; }
Integer representation of the form 0xRRGGBB.
public uint RawInt { get; }
Integer representation of the form 0xAABBGGRR as used by native code.
public static Color Random { get; }
Returns a random color out of 8 preset colors.
public string ToString( bool hex, bool rgba )
Converts the color to a string with given parameters.
hexConvert to Hex string if possible.rgbaConvert to CSS rgba function- Returns The string representation of this color.
public static Color Average( Color[] values )
Returns a color whose components are averaged of all given colors.
valuesThe colors to get average of.- Returns The average color.
public static Color Lerp( ref Color a, ref Color b, float frac, bool clamped = True )
Performs linear interpolation between two colors.
aThe source color.bThe target color.fracFraction to the target color. 0 will return source color, 1 will return target color, 0.5 will "mix" the 2 colors equally.clampedClamp fraction to range of [0,1]. If not clamped, the color will be extrapolated.- Returns The interpolated color.
public Color LerpTo( ref Color target, float frac, bool clamp = True )
Performs linear interpolation between this and given colors.
targetColor BfracFraction, where 0 would return this, 0.5 would return a point between this and given colors, and 1 would return the given color.clampWhether to clamp the fraction argument between [0,1]
public static Color FromBytes( int r, int g, int b, int a = 255 )
Creates a color from 0-255 range inputs, converting them to 0-1 range.
rThe red component.gThe green component.bThe blue component.aThe alpha/transparency component.
public static Color FromRgb( uint rgb )
Converts an integer of the form 0xRRGGBB into the color #RRGGBB with 100% alpha.
rgbInteger between 0x000000 and 0xffffff representing a color.
public static Color FromRgba( uint rgba )
Converts an integer of the form 0xRRGGBBAA into the color #RRGGBBAA.
rgbaInteger between 0x00000000 and 0xffffffff representing a color with alpha.
public Color AdjustHue( float amount )
Increases or decreases this color's hue
amountA number between -360 and 360 to add to the color's hue- Returns The adjusted color
public Color Darken( float fraction )
Darkens the color by given amount.
fractionHow much to darken the color by, in range of 0 (not at all) to 1 (fully black). Negative values will lighten the color.- Returns The darkened color.
public Color Lighten( float fraction )
Lightens the color by given amount.
fractionHow much to lighten the color by, in range of 0 (not at all) to 1 (double the color). Negative values will darken the color.- Returns The lightened color.
public Color Desaturate( float fraction )
Desaturates the color by given amount.
fractionHow much to desaturate the color by, in range of 0 (not at all) to 1 (no saturation, i.e. fully white). Negative values will saturate the color.- Returns The desaturated color.
public Color Saturate( float fraction )
Saturates the color by given amount.
fractionHow much to saturate the color by, in range of 0 (not at all) to 1 (double the saturation). Negative values will desaturate the color.- Returns The saturated color.
public int ComponentCountChangedBetweenColors( Color b )
Returns how many color components would be changed between this color and another color
public static Nullable<Color> Parse( string value )
Parse the color from a string. Many common formats are supported.
valueThe string to parse.- Returns The parsed color if operation completed successfully.
public static bool TryParse( string value, ref Color color )
Try to parse the color. Returns true on success
public static Color op_Multiply( ref Color c1, float f )
Multiply each component of this color by given value.
c1Color to multiply.fScalar value to multiply each color component by.- Returns The multiplication result.
public Type GetType( )
😔 No documentation found.
public ColorHsv ToHsv( )
😔 No documentation found.
public Color Invert( )
😔 No documentation found.
public string ToString( )
😔 No documentation found.
public static Color op_Multiply( ref Color c1, ref Color c2 )
😔 No documentation found.
public static Color op_Addition( ref Color c1, ref Color c2 )
😔 No documentation found.
public static Color op_Subtraction( ref Color c1, ref Color c2 )
😔 No documentation found.
public static Color op_Implicit( ref Vector4 value )
😔 No documentation found.
public static Color op_Implicit( ref Vector3 value )
😔 No documentation found.
public static Color op_Implicit( ref Color32 color )
😔 No documentation found.
public static Color op_Implicit( string value )
😔 No documentation found.
public float Item { get; set; }
😔 No documentation found.
public static bool op_Equality( ref Color left, ref Color right )
😔 No documentation found.
public static bool op_Inequality( ref Color left, ref Color right )
😔 No documentation found.
public bool Equals( object obj )
😔 No documentation found.
public int GetHashCode( )
😔 No documentation found.
public bool Equals( Color o )
😔 No documentation found.