Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LUT<TProps>

Style class for describing a table of colors with associated lookup values (numbers).

Instances of LUT, like all LCJS style classes, are immutable, meaning that its setters don't modify the actual object, but instead return a completely new modified object.

Properties of LUT:

  • steps: List of color steps (color + number value pair).
  • interpolate: true enables automatic linear interpolation between color steps.

LUT Behavior:

Example 1, LUT with interpolation disabled.

 const lut = new LUT({
     steps: [
         { value: 0, color: ColorRGBA( 0, 0, 0 ) },
         { value: 10, color: ColorRGBA( 255, 0, 0 ) },
         { value: 100, color: ColorRGBA( 0, 255, 0 ) }
     ],
     interpolate: false
 })
Lookup Value Color
value < 10 black
10 <= value < 100 red
100 <= value green

Example 2, LUT with interpolation enabled.

 const lut = new LUT({
     steps: [
         { value: 0, color: ColorRGBA( 0, 0, 0 ) },
         { value: 10, color: ColorRGBA( 255, 0, 0 ) },
         { value: 100, color: ColorRGBA( 0, 255, 0 ) }
     ],
     interpolate: true
 })
Lookup Value Color
value <= 0 black
0 < value < 10 interpolated between black and red
10 < value < 100 interpolated between red and green

LUT Usage:

Use LUT with:

Index

Constructors

constructor

  • Construct a LUT object, specifying any amount of its properties.

    Example 1, LUT with interpolation disabled.

     const lut = new LUT({
         steps: [
             { value: 0, color: ColorRGBA( 0, 0, 0 ) },
             { value: 10, color: ColorRGBA( 255, 0, 0 ) },
             { value: 100, color: ColorRGBA( 0, 255, 0 ) }
         ],
         interpolate: false
     })

    Example 2, LUT with interpolation enabled.

     const lut = new LUT({
         steps: [
             { value: 0, color: ColorRGBA( 0, 0, 0 ) },
             { value: 10, color: ColorRGBA( 255, 0, 0 ) },
             { value: 100, color: ColorRGBA( 0, 255, 0 ) }
         ],
         interpolate: true
     })

    Parameters

    Returns LUT

Methods

getColors

  • getColors(values: number): Color
  • getColors(values: number[]): Color[]
  • getColors(values: number[][]): Color[][]
  • Get the color associated with the given value.

    Example:

    const color = lut.getColors( 5 )

    Parameters

    • values: number

      Single value.

    Returns Color

    Associated color if the LUT is valid, otherwise fallback color.

  • Get the colors associated with the given collection of values.

    Example:

    const colors = lut.getColors( [ 5, 10, 15 ] )

    Parameters

    • values: number[]

      1D collection of value.

    Returns Color[]

    Collection of associated colors if the LUT is valid, otherwise fallback colors.

  • Get the colors associated with the given collection Matrix2D of values.

    Example:

    const colors = lut.getColors(
     [
       [ 3, 7, 9 ],
       [ 5, 10, 15 ]
     ]
    )

    Parameters

    • values: number[][]

      2D collection of values.

    Returns Color[][]

    Collection of associated colors if the LUT is valid, otherwise fallback colors.

getFallbackColor

  • getFallbackColor(): Color
  • Get fallback color of value the LUT.

    Returns Color

    Color object.

getInterpolation

  • getInterpolation(): boolean
  • Get interpolation behavior of the LUT.

    Returns boolean

    Intepolation behaviour state. True - gradient, False - uniform.

getSteps

  • Get collection of LUT steps.

    Returns LUTStep[]

    Collection of steps.

getTitle

  • getTitle(): string
  • Get title of the LUT.

    Returns string

    Title of the LUT as string.

getUnits

  • getUnits(): string
  • Get units of the LUT.

    Returns string

    Units of the LUT as string.

setFallbackColor

  • setFallbackColor(color: Color): this
  • Set fallback color. The following color would be used as a backup. Meaning, the LUT might be configured incorrectly or the data is incorrect.

    Parameters

    • color: Color

      Color object.

    Returns this

setInterpolation

  • setInterpolation(interpolate: boolean): this
  • Set interpolation behavior of the LUT, which describes the distribution of color for the data:

    • True: creates a gradient LUT using linear-interpolation (LERP) between colors, which were defined in the collection of steps.
    • False: creates a uniform LUT using step-function for each color to describe the range of values where this color is used.

    Parameters

    • interpolate: boolean

      Interpolation behavior: True - gradient, False - uniform.

    Returns this

setSteps

  • Set new collection of LUT steps.

    Parameters

    • steps: LUTStep[]

      Collection of color-value pairs.

    Returns this

setTitle

  • setTitle(title: string): this
  • Set title of the LUT, which describes the data.

    Parameters

    • title: string

      Title of the LUT.

    Returns this

setUnits

  • setUnits(units: string): this
  • Set units of the data-values in the LUT, which describes the data domain.

    Parameters

    • units: string

      Units of the LUT.

    Returns this

Static Factory

  • Factory(values?: Partial<TProps> | Iterable<[string, any]>): Record<TProps> & Readonly<TProps>
  • Type parameters

    • TProps: Object

    Parameters

    • values: Partial<TProps> | Iterable<[string, any]>

    Returns Record<TProps> & Readonly<TProps>

Static Record

  • Record(defaultValues: TProps, name?: undefined | string): Factory<TProps>
  • Unlike other types in Immutable.js, the Record() function creates a new Record Factory, which is a function that creates Record instances.

    See above for examples of using Record().

    Note: Record is a factory function and not a class, and does not use the new keyword during construction.

    Type parameters

    • TProps

    Parameters

    • defaultValues: TProps
    • name: undefined | string

    Returns Factory<TProps>

Static getDescriptiveName

  • getDescriptiveName(record: Record<any>): string
  • Records allow passing a second parameter to supply a descriptive name that appears when converting a Record to a string or in any error messages. A descriptive name for any record can be accessed by using this method. If one was not provided, the string "Record" is returned.

    const { Record } = require('immutable')
    const Person = Record({
      name: null
    }, 'Person')
    
    var me = Person({ name: 'My Name' })
    me.toString() // "Person { "name": "My Name" }"
    Record.getDescriptiveName(me) // "Person"

    Parameters

    Returns string

Static isRecord

  • isRecord(maybeRecord: any): maybeRecord
  • True if maybeRecord is an instance of a Record.

    Parameters

    • maybeRecord: any

    Returns maybeRecord