If you evaluate a ramp parameter on a node, Houdini will return a Ramp object.
You can check the curve “basis” of a ramp you get from a parameter by calling the hou.Ramp.basis method,which returns a hou.rampBasis value.
In the Hermite
basis, the curve passes through the odd control points,
and the even control points control the tangent at the previous point. See the
Wikipedia article on Hermite spline curves
for more information.
To get a smooth curve, you should evenly space the control points.
Methods ¶
__init__(basis, keys, values)
→ float
basis
A sequence of hou.rampBasis values, one for each key. The
ramp basis for a key determines how Houdini interpolates from the
key up until the next key. If there is no next key, Houdini will
hold the value constant until the end of the [0,1]
domain, regardless
of the ramp basis.
keys
A sequence of floats, one for each key, each between 0.0 and 1.0,
inclusive. Each key represents the location in the [0,1]
domain
of its corresponding value.
values
A sequence of values, where each value corresponds to a key. When asked to evaluate at a value where there is no key, Houdini will interpolate between adjacent values using the basis function for the key on the left.
This sequence is either a sequence of floats or a sequence of triples of floats. In the former case, the newly-created ramp will evaluate to a single floating-point value. In the latter case, it will evaluate to a color.
Raises hou.InvalidSize if the keys and values sequences are not
not same size, or if values
contains subsequences of floats that are
not 3 elements long.
>>> lin = hou.rampBasis.Linear # Create a ramp that linearly interpolates between 2.5 and 4.5. >>> r = hou.Ramp((lin, lin), (0, 1), (2.5, 4.5)) >>> r <hou.Ramp is_color=False num_keys=2 data=((t=0, 2.5), (t=1, 4.5))> >>> r.lookup(0.0) 2.5 >>> r.lookup(0.5) 3.5 >>> r.lookup(1.0) 4.5 # Create a color ramp that linearly interpolates from black to red. >>> hou.Ramp((lin, lin), (0, 1), ((0.0, 0.0, 0.0), (1.0, 0.0, 0.2))) <hou.Ramp is_color=True num_keys=2 data=((t=0, rgb=(0, 0, 0)), (t=1, rgb=(1, 1, 1)))>
isColor()
→ bool
Return True if this is a color ramp, and False if it is a single float ramp.
colorType()
→ colorType
If this is a color ramp, return the color space that is used during interpolation. The default is hou.colorType.RGB.
Raises hou.OperationFailed if this ramp is not a color ramp.
setColorType(hou.colorType)
If this is a color ramp, set the color space that is used during interpolation. The default is hou.colorType.RGB.
To obtain a more perceptually uniform interpolation, use hou.colorType.LAB. To obtain a ramp that matches the rainbow, use hou.colorType.HSV.
Raises hou.OperationFailed if this ramp is not a color ramp.
lookup(position)
→ float
or tuple
Return the value of the ramp at a specified position in the interval
[0.0, 1.0)
. position
will be clamped if outside this interval.
Returns a float (for floating-point value ramps) or a tuple of 3 floats (for color ramps).
basis()
→ tuple
of hou.rampBasis enum values
Return a tuple of hou.rampBasis enumeration values that determine how Houdini interpolates between the keys in the ramp. See hou.Ramp.__init__ for more information.
keys()
→ tuple
of float
Return a tuple of floats between 0.0 and 1.0 containing the ramp key positions. See hou.Ramp.__init__ for more information.
values()
→ tuple
of float
or tuple
of tuple
of float
Return a tuple of floats (for a float ramp) or a tuple of tuples of 3 floats (for a color ramp) corresponding to the values in the ramp stored at each key. See hou.Ramp.__init__ for more information.
See also |