Skip to content

ColorTransferFunction

Introduction

vtkColorTransferFunction is a color mapping in RGB or HSV space that uses piecewise hermite functions to allow interpolation that can be piecewise constant, piecewise linear, or somewhere in-between (a modified piecewise hermite function that squishes the function according to a sharpness parameter). The function also allows for the specification of the midpoint (the place where the function reaches the average of the two bounding nodes) as a normalize distance between nodes. See the description of class vtkPiecewiseFunction for an explanation of midpoint and sharpness.

Usage

js
// create color transfer function
const ctfun = vtkColorTransferFunction.newInstance();
ctfun.addRGBPoint(200.0, 1.0, 1.0, 1.0);
ctfun.addRGBPoint(2000.0, 0.0, 0.0, 0.0);

Methods

addHSVPoint

Add a point defined in HSV

ArgumentTypeRequiredDescription
xNumberYesThe index of the point.
hNumberYesDefines the hue of the color (between 0 and 1).
sNumberYesDefines the saturation of the color (between 0 and 1).
vNumberYesDefines the value of the color (between 0 and 1).

addHSVPointLong

Add a point defined in HSV

ArgumentTypeRequiredDescription
xNumberYesThe index of the point.
hNumberYesDefines the hue of the color (between 0 and 1).
sNumberYesDefines the saturation of the color (between 0 and 1).
vNumberYesDefines the value of the color (between 0 and 1).
midpointNumberNo
sharpnessNumberNo

addHSVSegment

Add a line defined in HSV

ArgumentTypeRequiredDescription
x1NumberYesThe index of the first point.
h1NumberYesDefines the hue of the color of the first point (between 0 and 1).
s1NumberYesDefines the saturation of the color of the first point (between 0 and 1).
v1NumberYesDefines the value of the color of the first point (between 0 and 1).
x2NumberYesThe index of the second point.
h2NumberYesDefines the hue of the colorof the second point (between 0 and 1).
s2NumberYesDefines the saturation of the color of the second point (between 0 and 1).
v2NumberYesDefines the value of the color of the second point (between 0 and 1).

addRGBPoint

Add a point defined in RGB

ArgumentTypeRequiredDescription
xNumberYesThe index of the point.
rNumberYesDefines the red component (between 0 and 1).
gNumberYesDefines the green component (between 0 and 1).
bNumberYesDefines the blue component (between 0 and 1).

addRGBPointLong

Add a point defined in RGB

ArgumentTypeRequiredDescription
xNumberYesThe index of the point.
rNumberYesDefines the red component (between 0 and 1).
gNumberYesDefines the green component (between 0 and 1).
bNumberYesDefines the blue component (between 0 and 1).
midpointNumberNo
sharpnessNumberNo

addRGBSegment

Add a line defined in RGB

ArgumentTypeRequiredDescription
x1NumberYesThe index of the first point.
r1NumberYesDefines the red component of the first point(between 0 and 1).
g1NumberYesDefines the green component of the first point(between 0 and 1).
b1NumberYesDefines the red component of the first point (between 0 and 1).
x2NumberYesThe index of the second point.
r2NumberYesDefines the red component of the second point (between 0 and 1).
g2NumberYesDefines the green component of the second point (between 0 and 1).
b2NumberYesDefines the blue component of the second point (between 0 and 1).

adjustRange

Remove all points out of the new range, and make sure there is a point at each end of that range.

ArgumentTypeRequiredDescription
rangeArray[Number]Yes

applyColorMap

ArgumentTypeRequiredDescription
colorMapYes

buildFunctionFromArray

Construct a color transfer function from a vtkDataArray. The order of values depends on the number of components of the array. 3 -> RGB 4 -> XRGB 5 -> RGBMS 6 -> XRGBMS

X represents the input value to a function RGB represents the red, green, and blue value output M represents the midpoint S represents sharpness

ArgumentTypeRequiredDescription
arrayvtkDataArrayYes

buildFunctionFromTable

Construct a color transfer function from a table.

ArgumentTypeRequiredDescription
xStartNumberYesThe index of the first point.
xEndNumberYesThe index of the first point.
sizeNumberYes
tableArray[Number]Yes

estimateMinNumberOfSamples

Estimates the minimum size of a table such that it would correctly sample this function.

ArgumentTypeRequiredDescription
x1NumberYes
x2NumberYes

extend

Method use to decorate a given object (publicAPI+model) with vtkColorTransferFunction characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesobjectNo(default: {})

fillFromDataPointer

Defines the nodes from an array ptr with the layout [X1, R1, G1, B1, X2, R2, G2, B2, ..., Xn, Rn, Gn, Bn] where n is the number of nodes.

ArgumentTypeRequiredDescription
nbNumberYes
ptrYes

findMinimumXDistance

Traverses the nodes to find the minimum distance.

getBlueValue

Get the blue color evaluated at the specified location

ArgumentTypeRequiredDescription
xNumberYesThe index of the point.

getColor

Get the RGB color evaluated at the specified location

ArgumentTypeRequiredDescription
xNumberYesThe index of the point.
rgbArray[Number]YesThe Array of the RGB color to fill.

getColorSpace

Get the color space of the color transfer function.

Returns

TypeDescription
ColorSpace

getGreenValue

Get the green color evaluated at the specified location

ArgumentTypeRequiredDescription
xNumberYesThe index of the point.

getIndexedColor

Get the color given an integer index.

ArgumentTypeRequiredDescription
idxNumberYesThe index of the point.
rgbaArray[Number]YesAn Array of the RGBA color.

getNodeValue

For the node specified by index, set/get the location (X), R, G, and B values, midpoint, and sharpness values at the node.

ArgumentTypeRequiredDescription
indexNumberYes
valArray[Number]Yes

getNumberOfAvailableColors

Get the number of available colors for mapping to.

getRedValue

Get the red color evaluated at the specified location

ArgumentTypeRequiredDescription
xNumberYesThe index of the point.

getScale

Get the scale of the color transfer function.

Returns

TypeDescription
Scale

getSize

Get the number of points which specify this function

getTable

Get a table of RGB colors at regular intervals along the function

ArgumentTypeRequiredDescription
xStartNumberYesThe index of the first point.
xEndNumberYesThe index of the second point.
sizeNumberYes
tableArray[Number]Yes

getUint8Table

ArgumentTypeRequiredDescription
xStartNumberYesThe index of the first point.
xEndNumberYesThe index of the first point.
sizeNumberYes
withAlphaBooleanYes

mapData

Map a set of scalars through the lookup table.

ArgumentTypeRequiredDescription
inputYes
outputYes
outFormatYes
inputOffsetYes

mapScalarsThroughTable

ArgumentTypeRequiredDescription
inputYes
outputYes
outFormatYes
inputOffsetYes

mapValue

Get the RGBA color evaluated at the specified location

ArgumentTypeRequiredDescription
xNumberYesThe index of the point.

movePoint

Moves point from oldX to newX.

It removed the point from oldX. If any point existed at newX, it will also be removed.

ArgumentTypeRequiredDescription
oldXNumberYesThe old index of the point.
newXNumberYesThe new index of the point.

newInstance

Method use to create a new instance of vtkColorTransferFunction

ArgumentTypeRequiredDescription
initialValuesobjectNofor pre-setting some of its content

removeAllPoints

Remove all points

removePoint

Remove a point

ArgumentTypeRequiredDescription
xNumberYesThe index of the point.

setColorSpace

Set the color space of the color transfer function.

ArgumentTypeRequiredDescription
colorSpaceColorSpaceYes

setNodeValue

For a specified index value, set the node parameters

ArgumentTypeRequiredDescription
indexNumberYes
valArray[Number]Yes

setNodes

Set nodes directly

ArgumentTypeRequiredDescription
nodesYes

Returns

TypeDescription
true if a change happen

setScale

Set the scale of the color transfer function.

ArgumentTypeRequiredDescription
scaleScaleYes

sortAndUpdateRange

Sort the vector in increasing order, then fill in the Range

Returns

TypeDescription
true if a change happen

updateRange

Returns

TypeDescription
true if a change happen