查找表(Lut)

优质
小牛编辑
117浏览
2023-12-01

表示颜色表的查找表,用于从一个数据值的范围中确定颜色值。

代码示例

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

构造函数

Lut( colormap, numberOfColors )

colormap - (可选)从预定义的颜色表中设置一个颜色表。可选值有:"rainbow"、 "cooltowarm"、 "blackbody"。 numberOfColors - (可选)设置用于表示数据数组的颜色数量。

属性

.minV : Float

查找表所表示的最小值,默认为0。

.maxV : Float

查找表所表示的最小值,默认为1。

.[legend]

查找表的图例。

方法

.copy ( lut : Lut ) : null this : Lut

color — 要拷贝的 Lut。

拷贝给定的 Lut。

.setLegendOn [parameters]

parameters - { layout: value, position: { x: value, y: value, z: value }, dimensions: { width: value, height: value } } layout — Horizontal or vertical layout. Default is vertical.
position — The position x,y,z of the legend.
dimensions — The dimensions (width and height) of the legend.

Sets this Lut with the legend on.

.setLegendOff

Sets this Lut with the legend off.

.setLegendLabels [parameters, callback]

parameters - { fontsize: value, fontface: value, title: value, um: value, ticks: value, decimal: value, notation: value } fontsize — Font size to be used for labels.
fontface — Font type to be used for labels.
title — The title of the legend.
um — The unit of measurements of the legend.
ticks — The number of ticks to be displayed.
decimal — The number of decimals to be used for legend values.
notation — Legend notation: standard (default) or scientific.
callback — An optional callback to be used to format the legend labels.

Sets the labels of the legend of this Lut.

.setMin ( minV : Float ) : Lut

minV — 查找表所表示的最小值。

将查找表要表示的最小值设为该值。

.setMax ( maxV : Float ) : Lut

maxV — 查找表所表示的最小值。

将查找表要表示的最大值设为该值。

.changeNumberOfColors ( numberOfColors : Float ) : Lut

numberOfColors — 用于表示数据数组的颜色数量。

设置查找表中要使用的颜色的数量。

.changeColorMap ( colorMap : Float ) : Lut

colorMap — 用于表示数据数组的颜色表名称。

设置查找表的颜色表为传入的颜色表。

.addColorMap ( colorMapName, arrayOfColors ) : Lut

插入一个新的颜色表到可用颜色表中。

.getColor ( value ) : Lut this : Lut

value -- 作为颜色展示的数据值。

返回一个Color

源码

examples/jsm/math/Lut.js