Table of Contents

Struct RGB

Namespace
RenderSharp
Assembly
RenderSharp.dll

A MathSharp.IVec3<TSelf, TBase, TFloat, TVFloat> of type byte. Values R, G and B all intended to lie within the range [0, 255].

public struct RGB : IVec3<RGB, byte, double, FVec3>, IEquatable<RGB>, ISwizzlable<RGB, byte>
Implements
IVec3<RGB, byte, double, FVec3>
ISwizzlable<RGB, byte>
Inherited Members

Constructors

RGB(byte, byte, byte)

Constructs a new color from the given red, green and blue channels.

public RGB(byte r, byte g, byte b)

Parameters

r byte

The red channel of the new color. Intended [0, 255].

g byte

The green channel of the new color. Intended [0, 255].

b byte

The blue channel of the new color. Intended [0, 255].

Properties

B

Blue channel. Intended to range [0, 255].

public byte B { get; set; }

Property Value

byte

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

byte

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

byte

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

byte

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

Dictionary<char, int>

X

The x component of the vector.

public byte X { readonly get; set; }

Property Value

byte

Y

The y component of the vector.

public byte Y { readonly get; set; }

Property Value

byte

Z

The z component of the vector.

public byte Z { readonly get; set; }

Property Value

byte

Methods

Cross(in RGB)

Computes the cross product between two vectors. (https://en.wikipedia.org/wiki/Cross_product).

public RGB Cross(in RGB rhs)

Parameters

rhs RGB

Returns

RGB

Dot(in RGB)

Computes the dot product between two vectors (https://en.wikipedia.org/wiki/Dot_product).

public byte Dot(in RGB other)

Parameters

other RGB

Returns

byte

Equals(RGB)

Computes whether two vectors are equal.

public bool Equals(RGB other)

Parameters

other RGB

Returns

bool

Mag()

Computes the magnitude of the vector.

public double Mag()

Returns

double

Mag2()

Computes the squared magnitude of the vector.

public byte Mag2()

Returns

byte

Norm()

Computes the normalized vector.

public FVec3 Norm()

Returns

FVec3

Norm(out double)

Computes the normalized vector.

public FVec3 Norm(out double mag)

Parameters

mag double

Returns

FVec3

Rotate(in RVec3)

Computes the rotated vector by the given angle vector using Euler rotation https://en.wikipedia.org/wiki/Rotation_matrix#General_3D_rotations.

public FVec3 Rotate(in RVec3 angle)

Parameters

angle RVec3

Returns

FVec3

A new floating point vector with the result of the rotation.

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.

ToFRGBA()

Returns the color expressed in FRGBA space.

public FRGBA ToFRGBA()

Returns

FRGBA

A new color with red, green and blue scaled down by 255, and an additional alpha 1.

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].

ToHSVA()

Returns the color expressed in HSVA space.

public HSVA ToHSVA()

Returns

HSVA

A new color with hue [0, 360], saturation and value [0, 1], and an additional alpha 1.

ToRGBA()

Returns the color expressed in RGBA space.

public RGBA ToRGBA()

Returns

RGBA

A new color with the same channels, and an additional alpha 255.

ToString()

Gets the string representation of the vector.

public override string ToString()

Returns

string

Operators

operator +(in RGB, in RGB)

Computes the sum of two vectors.

public static RGB operator +(in RGB lhs, in RGB rhs)

Parameters

lhs RGB
rhs RGB

Returns

RGB

operator /(in RGB, in RGB)

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 RGB operator /(in RGB lhs, in RGB rhs)

Parameters

lhs RGB
rhs RGB

Returns

RGB

operator /(in RGB, byte)

Computes the division of a vector by a scalar.

public static RGB operator /(in RGB lhs, byte scalar)

Parameters

lhs RGB
scalar byte

Returns

RGB

operator /(in RGB, double)

Computes the division of a vector by a scalar.

public static FVec3 operator /(in RGB lhs, double scalar)

Parameters

lhs RGB
scalar double

Returns

FVec3

implicit operator FRGB(in RGB)

Returns the color expressed in FRGB space.

public static implicit operator FRGB(in RGB rgb)

Parameters

rgb RGB

Returns

FRGB

A new color with red, green and blue scaled down by 255.

implicit operator FRGBA(in RGB)

Returns the color expressed in FRGBA space.

public static implicit operator FRGBA(in RGB rgb)

Parameters

rgb RGB

Returns

FRGBA

A new color with red, green and blue scaled down by 255, and an additional alpha 1.

implicit operator HSV(in RGB)

Returns the color expressed in HSV space.

public static implicit operator HSV(in RGB rgb)

Parameters

rgb RGB

Returns

HSV

A new color with hue [0, 360], saturation and value [0, 1].

implicit operator HSVA(in RGB)

Returns the color expressed in HSVA space.

public static implicit operator HSVA(in RGB rgb)

Parameters

rgb RGB

Returns

HSVA

A new color with hue [0, 360], saturation and value [0, 1], and an additional alpha 1.

implicit operator RGBA(in RGB)

Returns the color expressed in RGBA space.

public static implicit operator RGBA(in RGB rgb)

Parameters

rgb RGB

Returns

RGBA

A new color with the same channels, and an additional alpha 255.

implicit operator byte[](in RGB)

For implicitly converting the implementing type to a swizzle. i.e. Vec2 v["yx"] = other2;

public static implicit operator byte[](in RGB swizzler)

Parameters

swizzler RGB

Returns

byte[]

implicit operator RGB(byte[])

For implicitly converting a swizzle to the implementing type. i.e. Vec2 v = vec3["yz"];

public static implicit operator RGB(byte[] swizzle)

Parameters

swizzle byte[]

Returns

RGB

operator *(in RGB, in RGB)

Computes the Hadamard product of two vectors, also known as the component-wise product (https://en.wikipedia.org/wiki/Hadamard_product_(matrices)).

public static RGB operator *(in RGB lhs, in RGB rhs)

Parameters

lhs RGB
rhs RGB

Returns

RGB

operator *(in RGB, double)

Computes the product of a vector and a scalar.

public static FVec3 operator *(in RGB lhs, double scalar)

Parameters

lhs RGB
scalar double

Returns

FVec3

operator -(in RGB, in RGB)

Computes the difference of two vectors.

public static RGB operator -(in RGB lhs, in RGB rhs)

Parameters

lhs RGB
rhs RGB

Returns

RGB