c4d.Gradient

Gradient data type (CUSTOMDATATYPE_GRADIENT) for the GradientCustomGui GUI.

This type is called by value.

Inheritance

Members

Gradient.__init__([v])
Parameters: v (Gradient) – Copy constructor.
Return type: 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

:return:**True**if successful, otherwise False.

Gradient.DoubleKnots()

Inverts the knots.

Gradient.FlushKnots()

Flushes all knots.

Gradient.InitRender()

Initializes the renderer.

Return type: bool
Returns: True if successfull, otherwise False.
Gradient.FreeRender()

Free the render.

Gradient.CalcGradientPixel(pos)

Calculates a gradient pixel. Needs InitRender() before.

Parameters: pos (float) – X position.
Return type: 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 (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.
:type

Note

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

Check out this small example how to use:

col, brightness, pos, bias, index = gradient.GetKnot(index)
Parameters:
  • index (int) – Knot index.
  • col (Vector) – The color.
  • brightness (float) – The brightness.
  • pos (float:) – The position.
  • bias (float) – The bias.
  • index – The index.
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 (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) –

One of the following flags:

GRADIENT_INTERPOLATION int Interpolation
GRADIENT_KNOT BaseContainer Contains the knots as sub-containers.
GRADIENT_MODE int Mode
GRADIENT_UNCLAMPED bool Unclamped
Return type: Depends on id.
Returns: The data.
Gradient.SetData(id, data)

Gets a data item from the gradient container.

Parameters:
  • id (int) –

    One of the following flags:

    GRADIENT_INTERPOLATION int Interpolation
    GRADIENT_KNOT BaseContainer Contains the knots as sub-containers.
    GRADIENT_MODE int Mode
    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. Is just a copy of the original gradient. Can be changed, but has no effect to the original alpha-gradient.

Return type: Gradient
Returns: Alpha gradient.

Table Of Contents