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
// 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
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The index of the point. |
h | Number | Yes | Defines the hue of the color (between 0 and 1). |
s | Number | Yes | Defines the saturation of the color (between 0 and 1). |
v | Number | Yes | Defines the value of the color (between 0 and 1). |
addHSVPointLong
Add a point defined in HSV
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The index of the point. |
h | Number | Yes | Defines the hue of the color (between 0 and 1). |
s | Number | Yes | Defines the saturation of the color (between 0 and 1). |
v | Number | Yes | Defines the value of the color (between 0 and 1). |
midpoint | Number | No | |
sharpness | Number | No |
addHSVSegment
Add a line defined in HSV
| Argument | Type | Required | Description |
|---|---|---|---|
x1 | Number | Yes | The index of the first point. |
h1 | Number | Yes | Defines the hue of the color of the first point (between 0 and 1). |
s1 | Number | Yes | Defines the saturation of the color of the first point (between 0 and 1). |
v1 | Number | Yes | Defines the value of the color of the first point (between 0 and 1). |
x2 | Number | Yes | The index of the second point. |
h2 | Number | Yes | Defines the hue of the colorof the second point (between 0 and 1). |
s2 | Number | Yes | Defines the saturation of the color of the second point (between 0 and 1). |
v2 | Number | Yes | Defines the value of the color of the second point (between 0 and 1). |
addRGBPoint
Add a point defined in RGB
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The index of the point. |
r | Number | Yes | Defines the red component (between 0 and 1). |
g | Number | Yes | Defines the green component (between 0 and 1). |
b | Number | Yes | Defines the blue component (between 0 and 1). |
addRGBPointLong
Add a point defined in RGB
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The index of the point. |
r | Number | Yes | Defines the red component (between 0 and 1). |
g | Number | Yes | Defines the green component (between 0 and 1). |
b | Number | Yes | Defines the blue component (between 0 and 1). |
midpoint | Number | No | |
sharpness | Number | No |
addRGBSegment
Add a line defined in RGB
| Argument | Type | Required | Description |
|---|---|---|---|
x1 | Number | Yes | The index of the first point. |
r1 | Number | Yes | Defines the red component of the first point(between 0 and 1). |
g1 | Number | Yes | Defines the green component of the first point(between 0 and 1). |
b1 | Number | Yes | Defines the red component of the first point (between 0 and 1). |
x2 | Number | Yes | The index of the second point. |
r2 | Number | Yes | Defines the red component of the second point (between 0 and 1). |
g2 | Number | Yes | Defines the green component of the second point (between 0 and 1). |
b2 | Number | Yes | Defines 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.
| Argument | Type | Required | Description |
|---|---|---|---|
range | Array[Number] | Yes |
applyColorMap
| Argument | Type | Required | Description |
|---|---|---|---|
colorMap | Yes |
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
| Argument | Type | Required | Description |
|---|---|---|---|
array | vtkDataArray | Yes |
buildFunctionFromTable
Construct a color transfer function from a table.
| Argument | Type | Required | Description |
|---|---|---|---|
xStart | Number | Yes | The index of the first point. |
xEnd | Number | Yes | The index of the first point. |
size | Number | Yes | |
table | Array[Number] | Yes |
estimateMinNumberOfSamples
Estimates the minimum size of a table such that it would correctly sample this function.
| Argument | Type | Required | Description |
|---|---|---|---|
x1 | Number | Yes | |
x2 | Number | Yes |
extend
Method use to decorate a given object (publicAPI+model) with vtkColorTransferFunction characteristics.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | object | No | (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.
| Argument | Type | Required | Description |
|---|---|---|---|
nb | Number | Yes | |
ptr | Yes |
findMinimumXDistance
Traverses the nodes to find the minimum distance.
getBlueValue
Get the blue color evaluated at the specified location
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The index of the point. |
getColor
Get the RGB color evaluated at the specified location
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The index of the point. |
rgb | Array[Number] | Yes | The Array of the RGB color to fill. |
getColorSpace
Get the color space of the color transfer function.
Returns
| Type | Description |
|---|---|
| ColorSpace |
getDataPointer
Returns the nodes stored in the function, as an array of { x, r, g, b, midpoint, sharpness } objects. This is intended as a read-only reference to internally stored nodes that should not be modified outside the vtkColorTransferFunction object: direct writes bypass sortAndUpdateRange() and modified(), so the nodes can end up unsorted, the cached range stale, and the change will not propagate through the pipeline.
getGreenValue
Get the green color evaluated at the specified location
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The index of the point. |
getIndexedColor
Get the color given an integer index.
| Argument | Type | Required | Description |
|---|---|---|---|
idx | Number | Yes | The index of the point. |
rgba | Array[Number] | Yes | An 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.
| Argument | Type | Required | Description |
|---|---|---|---|
index | Number | Yes | |
val | Array[Number] | Yes |
getNumberOfAvailableColors
Get the number of available colors for mapping to.
getRedValue
Get the red color evaluated at the specified location
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The index of the point. |
getScale
Get the scale of the color transfer function.
Returns
| Type | Description |
|---|---|
| Scale |
getSize
Get the number of points which specify this function
getTable
Get a table of RGB colors at regular intervals along the function
| Argument | Type | Required | Description |
|---|---|---|---|
xStart | Number | Yes | The index of the first point. |
xEnd | Number | Yes | The index of the second point. |
size | Number | Yes | |
table | Array[Number] | Yes |
getUint8Table
| Argument | Type | Required | Description |
|---|---|---|---|
xStart | Number | Yes | The index of the first point. |
xEnd | Number | Yes | The index of the first point. |
size | Number | Yes | |
withAlpha | Boolean | Yes |
mapData
Map a set of scalars through the lookup table.
| Argument | Type | Required | Description |
|---|---|---|---|
input | Yes | ||
output | Yes | ||
outFormat | Yes | ||
inputOffset | Yes |
mapScalarsThroughTable
| Argument | Type | Required | Description |
|---|---|---|---|
input | Yes | ||
output | Yes | ||
outFormat | Yes | ||
inputOffset | Yes |
mapValue
Get the RGBA color evaluated at the specified location
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The 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.
| Argument | Type | Required | Description |
|---|---|---|---|
oldX | Number | Yes | The old index of the point. |
newX | Number | Yes | The new index of the point. |
newInstance
Method use to create a new instance of vtkColorTransferFunction
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | object | No | for pre-setting some of its content |
removeAllPoints
Remove all points
removePoint
Remove a point
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The index of the point. |
setColorSpace
Set the color space of the color transfer function.
| Argument | Type | Required | Description |
|---|---|---|---|
colorSpace | ColorSpace | Yes |
setNodeValue
For a specified index value, set the node parameters
| Argument | Type | Required | Description |
|---|---|---|---|
index | Number | Yes | |
val | Array[Number] | Yes |
setNodes
Set nodes directly
| Argument | Type | Required | Description |
|---|---|---|---|
nodes | Yes |
Returns
| Type | Description |
|---|---|
| true if a change happen |
setScale
Set the scale of the color transfer function.
| Argument | Type | Required | Description |
|---|---|---|---|
scale | Scale | Yes |
sortAndUpdateRange
Sort the vector in increasing order, then fill in the Range
Returns
| Type | Description |
|---|---|
| true if a change happen |
updateRange
Returns
| Type | Description |
|---|---|
| true if a change happen |