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

ColorF

2 overloads


public constructor ColorF1 → (2)

in : float32

Grayscale intensity value (linear sRGB), in the range [0..1].

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

in : float32

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

in : float32

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

opt : float32 = 1

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

Creates a new instance of ColorF.

FromARGB32


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.

FromARGB64


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

FromBGR24


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.

FromRGB24


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

FromSrgbF


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

FromSrgbI


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

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)

value in : float32

The value to modulate with.

returns → ColorF

The resulting color.

Modulates this color with the given value.


[Pure]
public method Mul2 → (1)

other in : ColorF

The color to modulate with.

returns → ColorF

The resulting color.

Modulates this color with the given one.

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.

ToARGB32


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

ToARGB64


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

ToSrgbF


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

ToSrgbI


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

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

G


public readonly attribute G → (float32)

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

Grayscale


public attribute Grayscale → (get)

value : float32

The luminance, see Colors.GrayscaleF.

Returns the grayscale luminance of this color value.

R


public readonly attribute R → (float32)

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