Struct RGBA
- Namespace
- RenderSharp
- Assembly
- RenderSharp.dll
A MathSharp.IVec4<TSelf, TBase, TFloat, TVFloat> of type double. Values R, G and B all intended to lie within the range [0, 1].
public struct RGBA : IVec4<RGBA, byte, double, FVec4>, IEquatable<RGBA>, ISwizzlable<RGBA, byte>
- Implements
- Inherited Members
Constructors
RGBA(in RGB, byte)
Constructs a new color from the given color vector and alpha channel.
public RGBA(in RGB rgb, byte a)
Parameters
rgb
RGBThe red, green and blue channels of the new color.
a
byteThe alpha channel of the new color.
RGBA(byte, byte, byte, byte)
Constructs a new color from the given red, green, blue and alpha channels.
public RGBA(byte r, byte g, byte b, byte a)
Parameters
r
byteThe red channel of the new color.
g
byteThe green channel of the new color.
b
byteThe blue channel of the new color.
a
byteThe alpha channel of the new color.
Properties
A
Alpha channel. Intended to range [0, 255].
public byte A { get; set; }
Property Value
B
Blue channel. Intended to range [0, 255].
public byte B { get; set; }
Property Value
Components
A new array representing the components of the vector.
public byte[] Components { get; }
Property Value
- byte[]
G
Green channel. Intended to range [0, 255].
public byte G { get; set; }
Property Value
this[int]
Indexer for the vector. 0 is the x component and so on.
public byte this[int i] { get; set; }
Parameters
i
int
Property Value
this[string]
Used to perform a swizzle. i.e. vec3["yz"] = vec3["xz"];
public byte[] this[string swizzle] { get; set; }
Parameters
swizzle
string
Property Value
- byte[]
R
Red channel. Intended to range [0, 255].
public byte R { get; set; }
Property Value
SwizzleMap
Mapping of swizzle characters to their index in the implementing type. i.e. SwizzleMap['x'] = 0, SwizzleMap['y'] = 1, etc.
public static Dictionary<char, int> SwizzleMap { get; }
Property Value
W
The w component of the vector.
public byte W { readonly get; set; }
Property Value
X
The x component of the vector.
public byte X { readonly get; set; }
Property Value
Y
The y component of the vector.
public byte Y { readonly get; set; }
Property Value
Z
The z component of the vector.
public byte Z { readonly get; set; }
Property Value
Methods
Dot(in RGBA)
Computes the dot product between two vectors (https://en.wikipedia.org/wiki/Dot_product).
public byte Dot(in RGBA other)
Parameters
other
RGBA
Returns
Equals(RGBA)
Computes whether two vectors are equal.
public bool Equals(RGBA other)
Parameters
other
RGBA
Returns
Mag()
Computes the magnitude of the vector.
public double Mag()
Returns
Mag2()
Computes the squared magnitude of the vector.
public byte Mag2()
Returns
Norm()
Computes the normalized vector.
public FVec4 Norm()
Returns
- FVec4
Norm(out double)
Computes the normalized vector.
public FVec4 Norm(out double mag)
Parameters
mag
double
Returns
- FVec4
ToFRGB()
Returns the color expressed in FRGB space.
public FRGB ToFRGB()
Returns
- FRGB
A new color with red, green and blue scaled down by 255, and alpha truncated.
ToFRGBA()
Returns the color expressed in FRGBA space.
public FRGBA ToFRGBA()
Returns
- FRGBA
A new color with red, green, blue and alpha scaled down by 255.
ToHSV()
Returns the color expressed in HSV space.
public HSV ToHSV()
Returns
- HSV
A new color with hue [0, 360], saturation and value [0, 1], and alpha truncated.
ToHSVA()
Returns the color expressed in HSVA space.
public HSVA ToHSVA()
Returns
- HSVA
A new color with hue [0, 360], and saturation, value and alpha [0, 1].
ToRGB()
Returns the color expressed in RGB space.
public RGB ToRGB()
Returns
- RGB
A new color with the same channels, but alpha truncated.
ToString()
Gets the string representation of the vector.
public override string ToString()
Returns
Operators
operator +(in RGBA, in RGBA)
Computes the sum of two vectors.
public static RGBA operator +(in RGBA lhs, in RGBA rhs)
Parameters
Returns
operator /(in RGBA, in RGBA)
Computes the Hadamar inverse product (division) of two vectors, also known as the component-wise inverse product (https://en.wikipedia.org/wiki/Hadamard_product_(matrices)).
public static RGBA operator /(in RGBA lhs, in RGBA rhs)
Parameters
Returns
operator /(in RGBA, double)
Computes the division of a vector by a scalar.
public static FVec4 operator /(in RGBA lhs, double scalar)
Parameters
Returns
- FVec4
explicit operator FRGB(in RGBA)
Returns the color expressed in FRGB space.
public static explicit operator FRGB(in RGBA rgba)
Parameters
rgba
RGBA
Returns
- FRGB
A new color with red, green and blue scaled down by 255, and alpha truncated.
explicit operator HSV(in RGBA)
Returns the color expressed in HSV space.
public static explicit operator HSV(in RGBA rgba)
Parameters
rgba
RGBA
Returns
- HSV
A new color with hue [0, 360], saturation and value [0, 1], and alpha truncated.
explicit operator RGB(in RGBA)
Returns the color expressed in RGB space.
public static explicit operator RGB(in RGBA rgba)
Parameters
rgba
RGBA
Returns
- RGB
A new color with the same channels, but alpha truncated.
implicit operator FRGBA(in RGBA)
Returns the color expressed in FRGBA space.
public static implicit operator FRGBA(in RGBA rgba)
Parameters
rgba
RGBA
Returns
- FRGBA
A new color with red, green, blue and alpha scaled down by 255.
implicit operator HSVA(in RGBA)
Returns the color expressed in HSVA space.
public static implicit operator HSVA(in RGBA rgba)
Parameters
rgba
RGBA
Returns
- HSVA
A new color with hue [0, 360], and saturation, value and alpha [0, 1].
implicit operator byte[](in RGBA)
For implicitly converting the implementing type to a swizzle. i.e. Vec2 v["yx"] = other2;
public static implicit operator byte[](in RGBA self)
Parameters
self
RGBA
Returns
- byte[]
implicit operator RGBA(byte[])
For implicitly converting a swizzle to the implementing type. i.e. Vec2 v = vec3["yz"];
public static implicit operator RGBA(byte[] swizzle)
Parameters
swizzle
byte[]
Returns
operator *(in RGBA, in RGBA)
Computes the Hadamard product of two vectors, also known as the component-wise product (https://en.wikipedia.org/wiki/Hadamard_product_(matrices)).
public static RGBA operator *(in RGBA lhs, in RGBA rhs)
Parameters
Returns
operator *(in RGBA, double)
Computes the product of a vector and a scalar.
public static FVec4 operator *(in RGBA lhs, double scalar)
Parameters
Returns
- FVec4
operator -(in RGBA, in RGBA)
Computes the difference of two vectors.
public static RGBA operator -(in RGBA lhs, in RGBA rhs)