c4d.Gradient

Gradient data type ( CUSTOMDATATYPE_GRADIENT ) for the GradientCustomGui GUI.

This type is called by value.

Definition

class c4d. Gradient

Inheritance

Members

Gradient. __init__ ( [ v ] )
Parameters: v ( c4d.Gradient ) – Copy constructor.
Return type: c4d.Gradient
Returns: The new gradient.
Gradient. __hash__ ( )

Returns a hash of the whole gradient state, including the needles, colors and interpolation type.:

print hash(obj) #hash calls obj.__hash__()
							
Return type: int
Returns: Hash value
Gradient. InvertKnots ( )

Inverts the knots.

Return type: bool
Returns: True if successful, otherwise False .
Gradient. DoubleKnots ( )

Doubles the knots.

Return type: bool
Returns: True if successful, otherwise False .
Gradient. FlushKnots ( )

Flushes all knots.

Gradient. InitRender ( irs )

Initializes the renderer.

Parameters: irs ( c4d.modules.render.InitRenderStruct ) – Information about the upcoming rendering.
Return type: bool
Returns: True if successfull, otherwise False .
Gradient. FreeRender ( )

Free the render.

Gradient. CalcGradientPixel ( pos )

Calculates a gradient pixel.

Note

This has to be done within a pair of InitRender() / FreeRender() calls.

Here is an example:

gradient = op[c4d.LIGHT_VISIBILITY_GRADIENT]
irs = render.InitRenderStruct()
if gradient.InitRender(irs):
  print gradient.CalcGradientPixel(0.5)
  gradient.FreeRender()
							
Parameters: pos ( float ) – X position.
Return type: c4d.Vector
Returns: Calculated pixel.
Gradient. InsertKnot ( [col][, brightness][, pos][, bias][, index] )

Insert a knot. Not passed arguments will be set with default values.

Parameters:
  • col ( c4d.Vector ) – The color.
  • brightness ( float ) – The brightness.
  • pos ( float ) – The position.
  • bias ( float ) – The bias.
  • index ( int ) – The index.
Return type:

int

Returns:

The new knot

Note

The new knot index is GetKnotCount() - 1

Gradient. RemoveKnot ( index )

Delete a knot.

Parameters: index ( int ) –

index knot.

Note

0 <= index < GetKnotCount()

Gradient. GetKnot ( index )

Returns the information about a knot.

Parameters: index ( int ) –

The index.

Note

The new knot index has to be 0 <= index < Gradient.GetKnotCount()

Check out this small example:

col, brightness, pos, bias, index = gradient.GetKnot(index)
							
Return type: dict{‘index’: int, col : Vector , brightness : float, pos : float, bias : float}
Returns: A dictionary with the knot information:
type index: int
key index: Knot index.
type col: c4d.Vector
key col: The color.
type brightness:
  float
key brightness: The brightness.
type pos: float
key pos: The position.
type bias: float
key bias: The bias.
Gradient. SetKnot ( index[, col][, brightness][, pos][, bias] )

Set the values of a knot. Just the passed arguments will be set, the other will be discarded.

Parameters:
  • index ( int ) –

    The knot index.

    Note

    The new knot index has to be 0 <= index < Gradient.GetKnotCount()

  • col ( c4d.Vector ) – The color.
  • brightness ( float ) – The brightness.
  • pos ( float ) – The position.
  • bias ( float ) – The bias.
Gradient. GetData ( id )

Gets a data item from the gradient container.

Parameters: id ( int ) –

Data ID:

GRADIENT_INTERPOLATION int Interpolation:
GRADIENT_INTERPOLATION_CUBICKNOT Cubic knot.
GRADIENT_INTERPOLATION_CUBICBIAS Cubic bias.
GRADIENT_INTERPOLATION_SMOOTHKNOT Smooth knot.
GRADIENT_INTERPOLATION_LINEARKNOT Linear knot.
GRADIENT_INTERPOLATION_LINEAR Linear.
GRADIENT_INTERPOLATION_NONE None.
GRADIENT_INTERPOLATION_EXP_UP Exponential up.
GRADIENT_INTERPOLATION_EXP_DOWN Exponential down.
GRADIENT_KNOT BaseContainer Contains the knots as sub-containers:
GRADIENTKNOT_COLOR Vector Color.
GRADIENTKNOT_BRIGHTNESS float Brightness.
GRADIENTKNOT_POSITION float Position.
GRADIENTKNOT_BIAS float Bias.
GRADIENTKNOT_ID int Index.
GRADIENT_MODE int Mode:
GRADIENTMODE_COLOR Color only.
GRADIENTMODE_ALPHA Alpha only.
GRADIENTMODE_COLORALPHA Color and alpha.
GRADIENT_UNCLAMPED bool Unclamped.
Return type: Depends on id .
Returns: The data.
Gradient. SetData ( id , data )

Sets a data item from the gradient container.

Parameters:
  • id ( int ) –

    Data ID:

    GRADIENT_INTERPOLATION int Interpolation:
    GRADIENT_INTERPOLATION_CUBICKNOT Cubic knot.
    GRADIENT_INTERPOLATION_CUBICBIAS Cubic bias.
    GRADIENT_INTERPOLATION_SMOOTHKNOT Smooth knot.
    GRADIENT_INTERPOLATION_LINEARKNOT Linear knot.
    GRADIENT_INTERPOLATION_LINEAR Linear.
    GRADIENT_INTERPOLATION_NONE None.
    GRADIENT_INTERPOLATION_EXP_UP Exponential up.
    GRADIENT_INTERPOLATION_EXP_DOWN Exponential down.
    GRADIENT_KNOT BaseContainer Contains the knots as sub-containers:
    GRADIENTKNOT_COLOR Vector Color.
    GRADIENTKNOT_BRIGHTNESS float Brightness.
    GRADIENTKNOT_POSITION float Position.
    GRADIENTKNOT_BIAS float Bias.
    GRADIENTKNOT_ID int Index.
    GRADIENT_MODE int Mode:
    GRADIENTMODE_COLOR Color only.
    GRADIENTMODE_ALPHA Alpha only.
    GRADIENTMODE_COLORALPHA Color and alpha.
    GRADIENT_UNCLAMPED bool Unclamped.
  • data (Depends on id .) – The data.
Gradient. GetKnotCount ( )

Gets the knot count.

Return type: int
Returns: Knot count.
Gradient. GetAlphaGradient ( )

Gets a copy of the alpha gradient. It is just a copy of the original gradient. Can be changed, but has no effect to the original alpha-gradient.

Return type: c4d.Gradient
Returns: Alpha gradient.

Table Of Contents