# [name]

Represents a lookup table for colormaps. It is used to determine the color values from a range of data values.

## Import

[name] is an add-on, and must be imported explicitly. See [link:#manual/introduction/Installation Installation / Addons].

`import { Lut } from 'three/addons/math/Lut.js';`

## Code Example

`const lut = new Lut( 'rainbow', 512 ); const color = lut.getColor( 0.5 );`

## Constructor

### [name]( [param:String colormap], [param:Number count] )

colormap - Sets a colormap from predefined colormaps. Available colormaps are: `rainbow`, `cooltowarm`, `blackbody`, `grayscale`. Default is `rainbow`.
count - Sets the number of colors used to represent the data array. Default is `32`.

## Properties

### [property:Array lut]

The lookup table for the selected color map represented as an array of [page:Color]s.

### [property:Array map]

The currently selected color map. Default is the `rainbow` color map.

### [property:Number minV]

The minimum value to be represented with the lookup table. Default is *0*.

### [property:Number maxV]

The maximum value to be represented with the lookup table. Default is *1*.

### [property:Number n]

The number of colors of the current selected color map. Default is `32`.

## Methods

### [method:this copy]( [param:Lut lut] ) [param:Lut this]

color — Lut to copy.

Copies the given lut.

### [method:this addColorMap]( [param:String name], [param:Array arrayOfColors] )

name — The name of the color map.
arrayOfColors — An array of color values. Each value is an array holding a threshold and the actual color value as a hexadecimal number.

Adds a color map to this [name] instance.

### [method:HTMLCanvasElement createCanvas]()

Creates a canvas in order to visualize the lookup table as a texture.

### [method:Color getColor]( [param:Number alpha] )

value -- the data value to be displayed as a color.

Returns an instance of [page:Color] for the given data value.

### [method:this setColorMap]( [param:String colormap], [param:Number count] )

colormap — The name of the color map.
count — The number of colors. Default is `32`.

Configure the lookup table for the given color map and number of colors.

### [method:this setMin]( [param:Number minV] )

minV — The minimum value to be represented with the lookup table

Sets this Lut with the minimum value to be represented.

### [method:this setMax]( [param:Number maxV] )

maxV — The maximum value to be represented with the lookup table.

Sets this Lut with the maximum value to be represented.

### [method:HTMLCanvasElement updateCanvas]( [param:HTMLCanvasElement canvas] )

Updates the canvas with the [name]'s data.

## Source

[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/Lut.js examples/jsm/math/Lut.js]