Table of Contents

Struct ColorBGRA

Namespace
Stride.Core.Mathematics
Assembly
Stride.Core.Mathematics.dll

Represents a 32-bit color (4 bytes) in the form of BGRA (in byte order: B, G, R, A).

[DataContract("ColorBGRA")]
[DataStyle(DataStyle.Compact)]
public struct ColorBGRA : IEquatable<ColorBGRA>, IFormattable
Implements

Constructors

ColorBGRA(Vector3, float)

Initializes a new instance of the ColorBGRA struct.

public ColorBGRA(Vector3 value, float alpha)

Parameters

value Vector3

The red, green, and blue components of the color.

alpha float

The alpha component of the color.

ColorBGRA(Vector4)

Initializes a new instance of the ColorBGRA struct.

public ColorBGRA(Vector4 value)

Parameters

value Vector4

The red, green, blue, and alpha components of the color.

ColorBGRA(byte)

Initializes a new instance of the ColorBGRA struct.

public ColorBGRA(byte value)

Parameters

value byte

The value that will be assigned to all components.

ColorBGRA(byte, byte, byte, byte)

Initializes a new instance of the ColorBGRA struct.

public ColorBGRA(byte red, byte green, byte blue, byte alpha)

Parameters

red byte

The red component of the color.

green byte

The green component of the color.

blue byte

The blue component of the color.

alpha byte

The alpha component of the color.

ColorBGRA(byte[])

Initializes a new instance of the ColorBGRA struct.

public ColorBGRA(byte[] values)

Parameters

values byte[]

The values to assign to the red, green, and blue, alpha components of the color. This must be an array with four elements.

Exceptions

ArgumentNullException

Thrown when values is null.

ArgumentOutOfRangeException

Thrown when values contains more or less than four elements.

ColorBGRA(int)

Initializes a new instance of the ColorBGRA struct.

public ColorBGRA(int bgra)

Parameters

bgra int

A packed integer containing all four color components in BGRA.

ColorBGRA(float)

Initializes a new instance of the ColorBGRA struct.

public ColorBGRA(float value)

Parameters

value float

The value that will be assigned to all components.

ColorBGRA(float, float, float, float)

Initializes a new instance of the ColorBGRA struct.

public ColorBGRA(float red, float green, float blue, float alpha)

Parameters

red float

The red component of the color.

green float

The green component of the color.

blue float

The blue component of the color.

alpha float

The alpha component of the color.

ColorBGRA(float[])

Initializes a new instance of the ColorBGRA struct.

public ColorBGRA(float[] values)

Parameters

values float[]

The values to assign to the red, green, and blue, alpha components of the color. This must be an array with four elements.

Exceptions

ArgumentNullException

Thrown when values is null.

ArgumentOutOfRangeException

Thrown when values contains more or less than four elements.

ColorBGRA(uint)

Initializes a new instance of the ColorBGRA struct.

public ColorBGRA(uint bgra)

Parameters

bgra uint

A packed integer containing all four color components in BGRA order.

Fields

A

The alpha component of the color.

[DataMember(3)]
public byte A

Field Value

byte

B

The blue component of the color.

[DataMember(0)]
public byte B

Field Value

byte

G

The green component of the color.

[DataMember(1)]
public byte G

Field Value

byte

R

The red component of the color.

[DataMember(2)]
public byte R

Field Value

byte

Properties

this[int]

Gets or sets the component at the specified index.

public byte this[int index] { get; set; }

Parameters

index int

The index of the component to access. Use 0 for the alpha component, 1 for the red component, 2 for the green component, and 3 for the blue component.

Property Value

byte

The value of the alpha, red, green, or blue component, depending on the index.

Exceptions

ArgumentOutOfRangeException

Thrown when the index is out of the range [0, 3].

Methods

Add(ColorBGRA, ColorBGRA)

Adds two colors.

public static ColorBGRA Add(ColorBGRA left, ColorBGRA right)

Parameters

left ColorBGRA

The first color to add.

right ColorBGRA

The second color to add.

Returns

ColorBGRA

The sum of the two colors.

Add(ref ColorBGRA, ref ColorBGRA, out ColorBGRA)

Adds two colors.

public static void Add(ref ColorBGRA left, ref ColorBGRA right, out ColorBGRA result)

Parameters

left ColorBGRA

The first color to add.

right ColorBGRA

The second color to add.

result ColorBGRA

When the method completes, completes the sum of the two colors.

AdjustContrast(ColorBGRA, float)

Adjusts the contrast of a color.

public static ColorBGRA AdjustContrast(ColorBGRA value, float contrast)

Parameters

value ColorBGRA

The color whose contrast is to be adjusted.

contrast float

The amount by which to adjust the contrast.

Returns

ColorBGRA

The adjusted color.

AdjustContrast(ref ColorBGRA, float, out ColorBGRA)

Adjusts the contrast of a color.

public static void AdjustContrast(ref ColorBGRA value, float contrast, out ColorBGRA result)

Parameters

value ColorBGRA

The color whose contrast is to be adjusted.

contrast float

The amount by which to adjust the contrast.

result ColorBGRA

When the method completes, contains the adjusted color.

AdjustSaturation(ColorBGRA, float)

Adjusts the saturation of a color.

public static ColorBGRA AdjustSaturation(ColorBGRA value, float saturation)

Parameters

value ColorBGRA

The color whose saturation is to be adjusted.

saturation float

The amount by which to adjust the saturation.

Returns

ColorBGRA

The adjusted color.

AdjustSaturation(ref ColorBGRA, float, out ColorBGRA)

Adjusts the saturation of a color.

public static void AdjustSaturation(ref ColorBGRA value, float saturation, out ColorBGRA result)

Parameters

value ColorBGRA

The color whose saturation is to be adjusted.

saturation float

The amount by which to adjust the saturation.

result ColorBGRA

When the method completes, contains the adjusted color.

Clamp(ColorBGRA, ColorBGRA, ColorBGRA)

Restricts a value to be within a specified range.

public static ColorBGRA Clamp(ColorBGRA value, ColorBGRA min, ColorBGRA max)

Parameters

value ColorBGRA

The value to clamp.

min ColorBGRA

The minimum value.

max ColorBGRA

The maximum value.

Returns

ColorBGRA

The clamped value.

Clamp(ref ColorBGRA, ref ColorBGRA, ref ColorBGRA, out ColorBGRA)

Restricts a value to be within a specified range.

public static void Clamp(ref ColorBGRA value, ref ColorBGRA min, ref ColorBGRA max, out ColorBGRA result)

Parameters

value ColorBGRA

The value to clamp.

min ColorBGRA

The minimum value.

max ColorBGRA

The maximum value.

result ColorBGRA

When the method completes, contains the clamped value.

Deconstruct(out byte, out byte, out byte, out byte)

Deconstructs the vector's components into named variables.

public void Deconstruct(out byte r, out byte g, out byte b, out byte a)

Parameters

r byte

The R component

g byte

The G component

b byte

The B component

a byte

The A component

Equals(ColorBGRA)

Determines whether the specified ColorBGRA is equal to this instance.

public bool Equals(ColorBGRA other)

Parameters

other ColorBGRA

The ColorBGRA to compare with this instance.

Returns

bool

true if the specified ColorBGRA is equal to this instance; otherwise, false.

Equals(object)

Determines whether the specified object is equal to this instance.

public override bool Equals(object value)

Parameters

value object

The object to compare with this instance.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

FromBgra(int)

Converts the color from a packed BGRA integer.

public static ColorBGRA FromBgra(int color)

Parameters

color int

A packed integer containing all four color components in BGRA order

Returns

ColorBGRA

A color.

FromBgra(uint)

Converts the color from a packed BGRA integer.

public static ColorBGRA FromBgra(uint color)

Parameters

color uint

A packed integer containing all four color components in BGRA order

Returns

ColorBGRA

A color.

FromRgba(int)

Converts the color from a packed RGBA integer.

public static ColorBGRA FromRgba(int color)

Parameters

color int

A packed integer containing all four color components in RGBA order

Returns

ColorBGRA

A color.

FromRgba(uint)

Converts the color from a packed RGBA integer.

public static ColorBGRA FromRgba(uint color)

Parameters

color uint

A packed integer containing all four color components in RGBA order

Returns

ColorBGRA

A color.

GetBrightness()

Gets the brightness.

public float GetBrightness()

Returns

float

The Hue-Saturation-Brightness (HSB) saturation for this Color

GetHashCode()

Returns a hash code for this instance.

public override int GetHashCode()

Returns

int

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

GetHue()

Gets the hue.

public float GetHue()

Returns

float

The Hue-Saturation-Brightness (HSB) saturation for this Color

GetSaturation()

Gets the saturation.

public float GetSaturation()

Returns

float

The Hue-Saturation-Brightness (HSB) saturation for this Color

Lerp(ColorBGRA, ColorBGRA, float)

Performs a linear interpolation between two colors.

public static ColorBGRA Lerp(ColorBGRA start, ColorBGRA end, float amount)

Parameters

start ColorBGRA

Start color.

end ColorBGRA

End color.

amount float

Value between 0 and 1 indicating the weight of end.

Returns

ColorBGRA

The linear interpolation of the two colors.

Remarks

Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.

Lerp(ref ColorBGRA, ref ColorBGRA, float, out ColorBGRA)

Performs a linear interpolation between two colors.

public static void Lerp(ref ColorBGRA start, ref ColorBGRA end, float amount, out ColorBGRA result)

Parameters

start ColorBGRA

Start color.

end ColorBGRA

End color.

amount float

Value between 0 and 1 indicating the weight of end.

result ColorBGRA

When the method completes, contains the linear interpolation of the two colors.

Remarks

Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.

Max(ColorBGRA, ColorBGRA)

Returns a color containing the largest components of the specified colorss.

public static ColorBGRA Max(ColorBGRA left, ColorBGRA right)

Parameters

left ColorBGRA

The first source color.

right ColorBGRA

The second source color.

Returns

ColorBGRA

A color containing the largest components of the source colors.

Max(ref ColorBGRA, ref ColorBGRA, out ColorBGRA)

Returns a color containing the smallest components of the specified colorss.

public static void Max(ref ColorBGRA left, ref ColorBGRA right, out ColorBGRA result)

Parameters

left ColorBGRA

The first source color.

right ColorBGRA

The second source color.

result ColorBGRA

When the method completes, contains an new color composed of the largest components of the source colorss.

Min(ColorBGRA, ColorBGRA)

Returns a color containing the smallest components of the specified colors.

public static ColorBGRA Min(ColorBGRA left, ColorBGRA right)

Parameters

left ColorBGRA

The first source color.

right ColorBGRA

The second source color.

Returns

ColorBGRA

A color containing the smallest components of the source colors.

Min(ref ColorBGRA, ref ColorBGRA, out ColorBGRA)

Returns a color containing the smallest components of the specified colors.

public static void Min(ref ColorBGRA left, ref ColorBGRA right, out ColorBGRA result)

Parameters

left ColorBGRA

The first source color.

right ColorBGRA

The second source color.

result ColorBGRA

When the method completes, contains an new color composed of the smallest components of the source colors.

Modulate(ColorBGRA, ColorBGRA)

Modulates two colors.

public static ColorBGRA Modulate(ColorBGRA left, ColorBGRA right)

Parameters

left ColorBGRA

The first color to modulate.

right ColorBGRA

The second color to modulate.

Returns

ColorBGRA

The modulated color.

Modulate(ref ColorBGRA, ref ColorBGRA, out ColorBGRA)

Modulates two colors.

public static void Modulate(ref ColorBGRA left, ref ColorBGRA right, out ColorBGRA result)

Parameters

left ColorBGRA

The first color to modulate.

right ColorBGRA

The second color to modulate.

result ColorBGRA

When the method completes, contains the modulated color.

Negate(ColorBGRA)

Negates a color.

public static ColorBGRA Negate(ColorBGRA value)

Parameters

value ColorBGRA

The color to negate.

Returns

ColorBGRA

The negated color.

Negate(ref ColorBGRA, out ColorBGRA)

Negates a color.

public static void Negate(ref ColorBGRA value, out ColorBGRA result)

Parameters

value ColorBGRA

The color to negate.

result ColorBGRA

When the method completes, contains the negated color.

Scale(ColorBGRA, float)

Scales a color.

public static ColorBGRA Scale(ColorBGRA value, float scale)

Parameters

value ColorBGRA

The color to scale.

scale float

The amount by which to scale.

Returns

ColorBGRA

The scaled color.

Scale(ref ColorBGRA, float, out ColorBGRA)

Scales a color.

public static void Scale(ref ColorBGRA value, float scale, out ColorBGRA result)

Parameters

value ColorBGRA

The color to scale.

scale float

The amount by which to scale.

result ColorBGRA

When the method completes, contains the scaled color.

SmoothStep(ColorBGRA, ColorBGRA, float)

Performs a cubic interpolation between two colors.

public static ColorBGRA SmoothStep(ColorBGRA start, ColorBGRA end, float amount)

Parameters

start ColorBGRA

Start color.

end ColorBGRA

End color.

amount float

Value between 0 and 1 indicating the weight of end.

Returns

ColorBGRA

The cubic interpolation of the two colors.

SmoothStep(ref ColorBGRA, ref ColorBGRA, float, out ColorBGRA)

Performs a cubic interpolation between two colors.

public static void SmoothStep(ref ColorBGRA start, ref ColorBGRA end, float amount, out ColorBGRA result)

Parameters

start ColorBGRA

Start color.

end ColorBGRA

End color.

amount float

Value between 0 and 1 indicating the weight of end.

result ColorBGRA

When the method completes, contains the cubic interpolation of the two colors.

Subtract(ColorBGRA, ColorBGRA)

Subtracts two colors.

public static ColorBGRA Subtract(ColorBGRA left, ColorBGRA right)

Parameters

left ColorBGRA

The first color to subtract.

right ColorBGRA

The second color to subtract

Returns

ColorBGRA

The difference of the two colors.

Subtract(ref ColorBGRA, ref ColorBGRA, out ColorBGRA)

Subtracts two colors.

public static void Subtract(ref ColorBGRA left, ref ColorBGRA right, out ColorBGRA result)

Parameters

left ColorBGRA

The first color to subtract.

right ColorBGRA

The second color to subtract.

result ColorBGRA

WHen the method completes, contains the difference of the two colors.

ToArray()

Creates an array containing the elements of the color.

public byte[] ToArray()

Returns

byte[]

A four-element array containing the components of the color in BGRA order.

ToBgra()

Converts the color into a packed integer.

public int ToBgra()

Returns

int

A packed integer containing all four color components.

ToColor3()

Converts the color into a three component color.

public Color3 ToColor3()

Returns

Color3

A three component color containing the red, green, and blue components of the color.

ToRgba()

Converts the color into a packed integer.

public int ToRgba()

Returns

int

A packed integer containing all four color components.

ToString()

Returns a string that represents this instance.

public override string ToString()

Returns

string

A string that represents this instance.

ToString(IFormatProvider)

Returns a string that represents this instance.

public string ToString(IFormatProvider formatProvider)

Parameters

formatProvider IFormatProvider

The format provider.

Returns

string

A string that represents this instance.

ToString(string)

Returns a string that represents this instance.

public string ToString(string format)

Parameters

format string

The format to apply to each channel (byte).

Returns

string

A string that represents this instance.

ToString(string, IFormatProvider)

Returns a string that represents this instance.

public string ToString(string format, IFormatProvider formatProvider)

Parameters

format string

The format to apply to each channel (byte).

formatProvider IFormatProvider

The format provider.

Returns

string

A string that represents this instance.

ToVector3()

Converts the color into a three component vector.

public Vector3 ToVector3()

Returns

Vector3

A three component vector containing the red, green, and blue components of the color.

ToVector4()

Converts the color into a four component vector.

public Vector4 ToVector4()

Returns

Vector4

A four component vector containing all four color components.

Operators

operator +(ColorBGRA, ColorBGRA)

Adds two colors.

public static ColorBGRA operator +(ColorBGRA left, ColorBGRA right)

Parameters

left ColorBGRA

The first color to add.

right ColorBGRA

The second color to add.

Returns

ColorBGRA

The sum of the two colors.

operator ==(ColorBGRA, ColorBGRA)

Tests for equality between two objects.

public static bool operator ==(ColorBGRA left, ColorBGRA right)

Parameters

left ColorBGRA

The first value to compare.

right ColorBGRA

The second value to compare.

Returns

bool

true if left has the same value as right; otherwise, false.

explicit operator ColorBGRA(Color3)

Performs an explicit conversion from Color3 to ColorBGRA.

public static explicit operator ColorBGRA(Color3 value)

Parameters

value Color3

The value.

Returns

ColorBGRA

The result of the conversion.

explicit operator ColorBGRA(Color4)

Performs an explicit conversion from Color4 to ColorBGRA.

public static explicit operator ColorBGRA(Color4 value)

Parameters

value Color4

The value.

Returns

ColorBGRA

The result of the conversion.

explicit operator Color3(ColorBGRA)

Performs an explicit conversion from ColorBGRA to Color3.

public static explicit operator Color3(ColorBGRA value)

Parameters

value ColorBGRA

The value.

Returns

Color3

The result of the conversion.

explicit operator Color4(ColorBGRA)

Performs an explicit conversion from ColorBGRA to Color4.

public static explicit operator Color4(ColorBGRA value)

Parameters

value ColorBGRA

The value.

Returns

Color4

The result of the conversion.

explicit operator Vector3(ColorBGRA)

Performs an explicit conversion from ColorBGRA to Vector3.

public static explicit operator Vector3(ColorBGRA value)

Parameters

value ColorBGRA

The value.

Returns

Vector3

The result of the conversion.

explicit operator Vector4(ColorBGRA)

Performs an explicit conversion from ColorBGRA to Vector4.

public static explicit operator Vector4(ColorBGRA value)

Parameters

value ColorBGRA

The value.

Returns

Vector4

The result of the conversion.

explicit operator int(ColorBGRA)

Performs an explicit conversion from ColorBGRA to int.

public static explicit operator int(ColorBGRA value)

Parameters

value ColorBGRA

The value.

Returns

int

The result of the conversion.

explicit operator ColorBGRA(Vector3)

Performs an explicit conversion from Vector3 to ColorBGRA.

public static explicit operator ColorBGRA(Vector3 value)

Parameters

value Vector3

The value.

Returns

ColorBGRA

The result of the conversion.

explicit operator ColorBGRA(Vector4)

Performs an explicit conversion from Vector4 to ColorBGRA.

public static explicit operator ColorBGRA(Vector4 value)

Parameters

value Vector4

The value.

Returns

ColorBGRA

The result of the conversion.

explicit operator ColorBGRA(int)

Performs an explicit conversion from int to ColorBGRA.

public static explicit operator ColorBGRA(int value)

Parameters

value int

The value.

Returns

ColorBGRA

The result of the conversion.

implicit operator ColorBGRA(Color)

Performs an implicit conversion from Color to ColorBGRA.

public static implicit operator ColorBGRA(Color value)

Parameters

value Color

The value.

Returns

ColorBGRA

The result of the conversion.

implicit operator Color(ColorBGRA)

Performs an implicit conversion from ColorBGRA to Color.

public static implicit operator Color(ColorBGRA value)

Parameters

value ColorBGRA

The value.

Returns

Color

The result of the conversion.

operator !=(ColorBGRA, ColorBGRA)

Tests for inequality between two objects.

public static bool operator !=(ColorBGRA left, ColorBGRA right)

Parameters

left ColorBGRA

The first value to compare.

right ColorBGRA

The second value to compare.

Returns

bool

true if left has a different value than right; otherwise, false.

operator *(ColorBGRA, ColorBGRA)

Modulates two colors.

public static ColorBGRA operator *(ColorBGRA left, ColorBGRA right)

Parameters

left ColorBGRA

The first color to modulate.

right ColorBGRA

The second color to modulate.

Returns

ColorBGRA

The modulated color.

operator *(ColorBGRA, float)

Scales a color.

public static ColorBGRA operator *(ColorBGRA value, float scale)

Parameters

value ColorBGRA

The factor by which to scale the color.

scale float

The color to scale.

Returns

ColorBGRA

The scaled color.

operator *(float, ColorBGRA)

Scales a color.

public static ColorBGRA operator *(float scale, ColorBGRA value)

Parameters

scale float

The factor by which to scale the color.

value ColorBGRA

The color to scale.

Returns

ColorBGRA

The scaled color.

operator -(ColorBGRA, ColorBGRA)

Subtracts two colors.

public static ColorBGRA operator -(ColorBGRA left, ColorBGRA right)

Parameters

left ColorBGRA

The first color to subtract.

right ColorBGRA

The second color to subtract.

Returns

ColorBGRA

The difference of the two colors.

operator -(ColorBGRA)

Negates a color.

public static ColorBGRA operator -(ColorBGRA value)

Parameters

value ColorBGRA

The color to negate.

Returns

ColorBGRA

A negated color.

operator +(ColorBGRA)

Assert a color (return it unchanged).

public static ColorBGRA operator +(ColorBGRA value)

Parameters

value ColorBGRA

The color to assert (unchange).

Returns

ColorBGRA

The asserted (unchanged) color.