Fade

Description

struct Tinman.Terrain.Util.Fade

A mapping from input values in a given range [a..b] to a normalized fade range [0..1].

The string representation (see Fade.ToString) has the following format:

  • '(0:a|b:1)'
    a := the input value that is mapped to fade value zero
    b := the input value that is mapped to fade value one

  • '(0:)'
    AlwaysZero

  • '(:1)'
    AlwaysOne

Public / Constants

Always​One


public static readonly attribute AlwaysOne → (Fade)

A non-invertible fade range that returns 1.0 for all input values.

Always​Zero


public static readonly attribute AlwaysZero → (Fade)

A non-invertible fade range that returns 0.0 for all input values.

Unit


public static readonly attribute Unit → (Fade)

The unit fade range that maps [0..1] to [0..1].

Public / Constructors

For


public static method For → (2)

zero in : float64

The input value for which to return 0.0.

one in : float64

The input value for which to return 1.0.

returns → Fade

The fade range. If zero in is equal to one in or either one is not a number (see Maths.IsNumber), the returned value will be AlwaysOne iff both zero in and one in are less than 0.0; otherwise it will be AlwaysZero.

Creates a new instance of Fade.

Public / Methods

Add


[Pure]
public method Add → (1)

value in : float64

The value.

returns → Fade

The resulting fade range.

Adds the given value in to fade range boundaries:

before: [a .. b]

Add(x)

after: [a + x .. b + x]

Compute


[Pure]
public method Compute → (1)

value in : float64

The input value.

returns → float64

The clamped fade value.

Computes the clamped fade value for the given input value.

Compute​Inverse


[Pure]
public method ComputeInverse → (1)

fade in : float64

The fade value.

returns → float64

The input value. Will be Maths.NanD if IsInvertible returns false.

Computes the input value for the given fade value.

Flip


[Pure]
public method Flip → ()

returns → Fade

The resulting fade range.

Flips the fade range boundaries:

before: [a .. b]

Flip()

after: [b .. a]

Is​Always


[Pure]
public method IsAlways → (1)

value in : float64

The constant value to check for.

returns → bool

true if the fade always has the given value in,
false if it does not.

Does this fade always have the given constant value?

Mul


[Pure]
public method Mul → (1)

value in : float64

The value.

returns → Fade

The resulting fade range.

Multiplies the fade range boundaries with the given value in:

before: [a .. b]

Mul(x)

after: [a * x .. b * x]
See also

Fade.For

To​Linear​D


[Pure]
public method ToLinearD → ()

returns → Vec2D

The coefficient vector: Vec2D.X holds m, Vec2D.Y holds b.

Returns this fade range as a linear function:

y = m * x + b

where y is the fade range value and x is the input value.

To​Linear​F


[Pure]
public method ToLinearF → ()

returns → Vec2F

The coefficient vector: Vec2F.X holds m, Vec2F.Y holds b.

Returns this fade range as a linear function:

y = m * x + b

where y is the fade range value and x is the input value.

Union


[Pure]
public method Union → (1)

other in : Fade

The other fade range.

returns → Fade

The resulting fade range.

Computes the union of this fade range and the given other in one.

Public / Attributes

Is​Invertible


public attribute IsInvertible → (get)

value : bool

true if ComputeInverse method will return well-defined values,
false if this fade range is not invertible.

Can the ComputeInverse method be used on this fade range?

Serialization

Serializer


public static readonly attribute Serializer → (ITypeSerializer<Fade>)

The serialization helper object for values of Fade.