TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

struct ColorF in Tinman.Core.Util

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

struct ColorF implements IConfigurable
  IEquatable<ColorF>

Remarks

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.

Configuration

ToConfig

public method ToConfig ()
type ConfigValue

Public / Constants

Black

The color 'Black' (see Black).

public static readonly field Black
type ColorF

White

The color 'White' (see White).

public static readonly field White
type ColorF

Public / Attributes

A

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

public readonly field A
type float32

B

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

public readonly field B
type float32

G

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

public readonly field G
type float32

R

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

public readonly field R
type float32

Public / Constructors

ColorF

Creates a new instance of ColorF.

public constructor ColorF (float32 i, float32 a = 1)
params i Grayscale intensity value (linear sRGB), in the range [0..1].
  a Alpha channel value (linear), in the range [0..1]. Defaults to 1.

Creates a new instance of ColorF.

public constructor ColorF (float32 r, float32 g, float32 b, float32 a = 1)
params r Red channel value (linear sRGB), in the range [0..1].
  g Green channel value (linear sRGB), in the range [0..1].
  b Blue channel value (linear sRGB), in the range [0..1].
  a Alpha channel value (linear), in the range [0..1]. Defaults to 1.

FromARGB32

Returns a ColorF value for the given color value.

public static method FromARGB32 (int32 argb32)
type ColorF
params argb32 The 32-bit A8R8G8B8 compressed sRGB color value.
returns The ColorF value.

See also:

Colors.Decode_A8R8G8B8

FromARGB64

Returns a ColorF value for the given color value.

public static method FromARGB64 (int64 argb64)
type ColorF
params argb64 The 64-bit A16R16G16B16 linear sRGB color value.
returns The ColorF value.

See also:

Colors

FromBGR24

Returns a ColorF value for the given color value.

public static method FromBGR24 (int32 bgr24, int32 alpha8 = 255)
type ColorF
params bgr24 The 24-bit B8G8R8 compressed sRGB color value.
  alpha8 The 8-bit linear alpha value. Defaults to 255.
returns The ColorF value.

See also:

Colors.Decode_B8G8R8

FromRGB24

Returns a ColorF value for the given color value.

public static method FromRGB24 (int32 rgb24, int32 alpha8 = 255)
type ColorF
params rgb24 The 24-bit R8G8B8 compressed sRGB color value.
  alpha8 The 8-bit linear alpha value. Defaults to 255.
returns The ColorF value.

See also:

Colors.Decode_R8G8B8

Public / Methods

Equals

public method Equals (ColorF other)
type bool
params other

FromSrgbF

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

[Pure]
public static method FromSrgbF (float32 value)
type float32
params value The compressed sRGB color channel value, in the range [0..1].
returns The linear sRGB color channel value, in the range [0..1].

Remarks:

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

FromSrgbI

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

[Pure]
public static method FromSrgbI (int32 value)
type int32
params value The compressed sRGB color channel value, in the range [0..65535].
returns The linear sRGB color channel value, in the range [0..65535].

Remarks:

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.

GetHashCode

public override method GetHashCode ()
type int32

Mul

Modulates this color with the given one.

[Pure]
public method Mul (ColorF other)
type ColorF
params other The color to modulate with.
returns The resulting color.

Opaque

public method Opaque (float32 a = 1)
type ColorF
params a

Round

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

[Pure]
public method Round ()
type ColorF
returns The rounded color value.

ToARGB32

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

[Pure]
public method ToARGB32 ()
type int32
returns The 32-bit A8R8G8B compressed sRGB color value.

See also:

Colors.Encode_A8R8G8B8

ToARGB64

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

[Pure]
public method ToARGB64 ()
type int64
returns The 64-bit A16R16G16B16 linear sRGB color value.

ToSrgbF

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

[Pure]
public static method ToSrgbF (float32 value)
type float32
params value The linear sRGB color channel value in the range [0..1].
returns The compressed sRGB color channel value in the range [0..1].

Remarks:

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

ToSrgbI

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

[Pure]
public static method ToSrgbI (int32 value)
type int32
params value The linear sRGB color channel value in the range [0..65535].
returns The compressed sRGB color channel value in the range [0..65535].

Remarks:

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.