ColorF

Description

struct Tinman.Core.Util.ColorF

A linear sRGB color value, with 32-bit floating-point precision for the color and alpha channels.

The color channel values (red, green and blue) are expected to be specified in linear sRGB color space (e.g. without gamma compression). This assumption is necessary, since the ColorF class uses linear arithmetic on color channel values.

Alpha channel values are always treated as linear.

Public / Constants

Black


public static readonly attribute Black → (ColorF)

The color 'Black' (see Colors.Black).

White


public static readonly attribute White → (ColorF)

The color 'White' (see Colors.White).

Zero


public static readonly attribute Zero → (ColorF)

The color 'Zero' (see Colors.Zero).

Public / Constructors

Color​F

2 overloads


public constructor ColorF1 → (2)

in : float32

Grayscale intensity value (linear sRGB), in the range [0..1] or greater for high-dynamic range.

opt : float32 = 1

Alpha channel value (linear), in the range [0..1].

Creates a new instance of ColorF.


public constructor ColorF2 → (4)

in : float32

Red channel value (linear sRGB), in the range [0..1] or greater for high-dynamic range.

in : float32

Green channel value (linear sRGB), in the range [0..1] or greater for high-dynamic range.

in : float32

Blue channel value (linear sRGB), in the range [0..1] or greater for high-dynamic range.

opt : float32 = 1

Alpha channel value (linear), in the range [0..1].

Creates a new instance of ColorF.

From​ARGB32


public static method FromARGB32 → (1)

argb32 in : int32

The 32-bit A8R8G8B8 compressed sRGB color value.

returns → ColorF

The ColorF value.

Returns a ColorF value for the given color value.

From​ARGB64


public static method FromARGB64 → (1)

argb64 in : int64

The 64-bit A16R16G16B16 linear sRGB color value.

returns → ColorF

The ColorF value.

Returns a ColorF value for the given color value.

See also

Colors

From​BGR24


public static method FromBGR24 → (2)

bgr24 in : int32

The 24-bit B8G8R8 compressed sRGB color value.

alpha8 opt : int32 = 255

The 8-bit linear alpha value.

returns → ColorF

The ColorF value.

Returns a ColorF value for the given color value.

From​RGB24


public static method FromRGB24 → (2)

rgb24 in : int32

The 24-bit R8G8B8 compressed sRGB color value.

alpha8 opt : int32 = 255

The 8-bit linear alpha value.

returns → ColorF

The ColorF value.

Returns a ColorF value for the given color value.

Public / Methods

Clamp


[Pure]
public method Clamp → ()

returns → ColorF

The resulting value.

Clamps all color channel values to [0..1].

From​Srgb​F


[Pure]
public static method FromSrgbF → (1)

value in : float32

The compressed sRGB color channel value, in the range [0..1].

returns → float32

The linear sRGB color channel value, in the range [0..1].

Transforms the given compressed sRGB color channel value into a linear sRGB color channel value.

This method uses the exact sRGB formula, which can decrease performance when used in tight loops.

See also

ColorF.FromSrgbI

From​Srgb​I


[Pure]
public static method FromSrgbI → (1)

value in : int32

The compressed sRGB color channel value, in the range [0..65535].

returns → int32

The linear sRGB color channel value, in the range [0..65535].

Transforms the given compressed sRGB color channel value into a linear sRGB color channel value.

This method uses a look-up table, which provides good performance, even if used in tight loops. Color channel values less than 0 resp. greater than 65535 are clamped to the respective bound.

See also

ColorF.FromSrgbF

Mix


[Pure]
public method Mix → (2)

other in : ColorF

The color to mix with.

in : float32

The mix factor: 0 yields this color, 1 yields other in.

returns → ColorF

The mixed color.

Mixes this color with the given color.

Mul

2 overloads


[Pure]
public method Mul1 → (1)

other in : ColorF

The color to modulate with.

returns → ColorF

The resulting color.

Modulates this color with the given one.


[Pure]
public method Mul2 → (1)

value in : float32

The value to modulate with.

returns → ColorF

The resulting color.

Modulates this color with the given value, excluding the alpha channel.

Opaque


[Pure]
public method Opaque → (1)

opt : float32 = 1

The new alpha value.

returns → ColorF

The resulting color.

Sets the alpha value of this color.

Round16


[Pure]
public method Round16 → ()

returns → ColorF

The rounded color value.

Rounds and clamps this color value so that calling ToARGB64 and FromARGB64 in sequence will yield the same ColorF value.

Round8


[Pure]
public method Round8 → ()

returns → ColorF

The rounded color value.

Rounds and clamps this color value so that calling ToARGB32 and FromARGB32 in sequence will yield the same ColorF value.

To​ARGB32


[Pure]
public method ToARGB32 → ()

returns → int32

The 32-bit A8R8G8B compressed sRGB color value.

Converts this ColorF value into a 32-bit A8R8G8B compressed sRGB color value.

To​ARGB64


[Pure]
public method ToARGB64 → ()

returns → int64

The 64-bit A16R16G16B16 linear sRGB color value.

Converts this ColorF value into a 64-bit A16R16G16B16 linear sRGB color value.

To​Srgb​F


[Pure]
public static method ToSrgbF → (1)

value in : float32

The linear sRGB color channel value in the range [0..1].

returns → float32

The compressed sRGB color channel value in the range [0..1].

Transforms the given linear sRGB color channel value into a compressed sRGB color channel value.

This method uses the exact sRGB formula, which can decrease performance when used in tight loops.

See also

ColorF.ToSrgbI

To​Srgb​I


[Pure]
public static method ToSrgbI → (1)

value in : int32

The linear sRGB color channel value in the range [0..65535].

returns → int32

The compressed sRGB color channel value in the range [0..65535].

Transforms the given linear sRGB color channel value into a compressed sRGB color channel value.

This method uses a look-up table, which provides good performance, even if used in tight loops. Color channel values less than 0 resp. greater than 65535 are clamped to the respective bound.

See also

ColorF.ToSrgbF

Public / Attributes

A


public readonly attribute A → (float32)

Alpha channel value (linear), in the range [0..1].

B


public readonly attribute B → (float32)

Blue channel value (linear sRGB), in the range [0..1] or greater for high-dynamic range.

G


public readonly attribute G → (float32)

Green channel value (linear sRGB), in the range [0..1] or greater for high-dynamic range.

Grayscale


public attribute Grayscale → (get)

value : float32

The luminance, see Colors.GrayscaleF.

Returns the grayscale luminance of this color value.

Is​Hdr


public attribute IsHdr → (get)

value : bool

true if one or more color channel values are greater than 1,
false if all color channel values are less than or equal to 1.

Is this a high-dynamic range color value?

Max


public attribute Max → (get)

value : float32

The color channel maximum.

Returns the maximum of the red, green and blue channels.

R


public readonly attribute R → (float32)

Red channel value (linear sRGB), in the range [0..1] or greater for high-dynamic range.

RGB


public attribute RGB → (get)

value : Vec3F

The (R,G,B) vector.

Returns the red, green and blue channels as a vector.

RGBA


public attribute RGBA → (get)

value : Vec4F

The (R,G,B,A) vector.

Returns the red, green, blue and alpha channels as a vector.

Serialization

Serializer


public static readonly attribute Serializer → (ITypeSerializerEx<ColorF>)

The serialization helper object for values of ColorF.