Gradient Class Reference

#include <customgui_gradient.h>

Inheritance diagram for Gradient:

Detailed Description

Gradient data type (CUSTOMDATATYPE_GRADIENT) for GradientCustomGui.

Note
Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Private Member Functions

 Gradient ()
 
 ~Gradient ()
 

Alloc/Free

static GradientAlloc ()
 
static void Free (Gradient *&grad)
 

Alpha

static void ConvertToAlphaGradient (BaseContainer *bc, Int32 id)
 
GradientGetAlphaGradient ()
 
GradientAllocAlphaGradient ()
 
void ConvertToAlphaGradient ()
 
Bool CopyFrom (const Gradient *src)
 

Knots

Bool InvertKnots ()
 
Bool DoubleKnots ()
 
Bool DistributeKnots ()
 
void FlushKnots ()
 

Render

maxon::Result< void > InitRender (const InitRenderStruct &irs)
 
void FreeRender ()
 
Vector CalcGradientPixel (Float pos) const
 
const GradientKnotGetRenderKnot (Int32 index) const
 
Int32 GetRenderKnotCount () const
 

Knot

Int32 GetKnotCount () const
 
Int32 InsertKnot (const GradientKnot &knot)
 
Bool RemoveKnot (Int32 index)
 
GradientKnot GetKnot (Int32 index) const
 
void SetKnot (Int32 index, const GradientKnot &k)
 

Data

GeData GetData (Int32 id) const
 
Bool SetData (Int32 id, const GeData &data)
 

Miscellaneous

UInt32 GetChecksum () const
 
void GetGradient (maxon::Gradient &gradient) const
 
void SetGradient (maxon::Gradient &gradient)
 

Constructor & Destructor Documentation

◆ Gradient()

Gradient ( )
private

◆ ~Gradient()

~Gradient ( )
private

Member Function Documentation

◆ Alloc()

static Gradient* Alloc ( )
static

Allocates a gradient data. Destroy the allocated gradient data with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Returns
The allocated gradient data, or nullptr if the allocation failed.

◆ Free()

static void Free ( Gradient *&  grad)
static

Destructs gradient data allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]gradThe gradient data to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ InvertKnots()

Bool InvertKnots ( )

Inverts the knots.

Returns
true if the knots were successfully inverted, otherwise false.

◆ DoubleKnots()

Bool DoubleKnots ( )

Doubles the knots.

Returns
true if the knots were successfully doubled, otherwise false.

◆ DistributeKnots()

Bool DistributeKnots ( )

Distributes the knots evenly.

Returns
true if the knots were successfully distributed, otherwise false.

◆ FlushKnots()

void FlushKnots ( )

Flushes all the knots.

◆ InitRender()

maxon::Result<void> InitRender ( const InitRenderStruct irs)

Initializes the gradient data for render.

Note
Call before CalcGradientPixel().
Parameters
[in]irsA struct with information about the upcoming gradient calculation.
Returns
true if successful, otherwise false.

◆ FreeRender()

void FreeRender ( )

Frees the gradient data from render.

Note
Call after gradient calculation is finished.

◆ CalcGradientPixel()

Vector CalcGradientPixel ( Float  pos) const

Calculates a gradient pixel.

Parameters
[in]posThe X position.
Returns
The calculated gradient pixel.

◆ GetRenderKnot()

const GradientKnot* GetRenderKnot ( Int32  index) const

Gets a pointer to the knot at index between InitRender() and FreeRender().

Parameters
[in]indexThe knot index. 0 <= index < GetRenderKnotCount()
Returns
The render knot at index. The gradient data owns the pointed knot.

◆ GetRenderKnotCount()

Int32 GetRenderKnotCount ( ) const

Gets the number of knots for GetRenderKnot().

Returns
The render knot count.

◆ GetKnotCount()

Int32 GetKnotCount ( ) const

Gets the number of knots.

Returns
The knot count.

◆ InsertKnot()

Int32 InsertKnot ( const GradientKnot knot)

Inserts a knot.

Parameters
[in]knotThe knot to insert.
Returns
The index of the inserted knot: GetKnotCount() - 1

◆ RemoveKnot()

Bool RemoveKnot ( Int32  index)

Removes a knot.

Parameters
[in]indexThe knot index. 0 <= index < GetKnotCount()
Returns
true if the knot was successfully removed, otherwise false.

◆ GetKnot()

GradientKnot GetKnot ( Int32  index) const

Gets the knot at index.

Parameters
[in]indexThe knot index. 0 <= index < GetKnotCount()
Returns
The knot.

◆ SetKnot()

void SetKnot ( Int32  index,
const GradientKnot k 
)

Sets knot at index.

Parameters
[in]indexThe knot index. 0 <= index < GetKnotCount()
[in]kThe knot.

◆ GetData()

GeData GetData ( Int32  id) const

Gets data from the gradient container.

Parameters
[in]idThe gradient data ID: GRADIENT_CONTAINERIDS
Returns
The data.

◆ SetData()

Bool SetData ( Int32  id,
const GeData data 
)

Sets data in the gradient container.

Parameters
[in]idThe gradient data ID: GRADIENT_CONTAINERIDS
[in]dataThe data.
Returns
true if successful, otherwise false.

◆ GetAlphaGradient()

Gradient* GetAlphaGradient ( )

Gets the alpha gradient.

Returns
The alpha gradient. The gradient data owns the pointed alpha gradient.

◆ AllocAlphaGradient()

Gradient* AllocAlphaGradient ( )

Allocates an alpha gradient.

Returns
The allocated alpha gradient, or nullptr if the allocation failed. The gradient data owns the pointed alpha gradient.

◆ ConvertToAlphaGradient() [1/2]

void ConvertToAlphaGradient ( )

Converts this gradient to an alpha gradient.

◆ CopyFrom()

Bool CopyFrom ( const Gradient src)

Copies all gradient data from the source gradient.

Since
R19
Parameters
[in]srcThe source gradient.
Returns
true if successful, otherwise false.

◆ ConvertToAlphaGradient() [2/2]

static void ConvertToAlphaGradient ( BaseContainer bc,
Int32  id 
)
static

Converts a gradient within a container into an alpha gradient.

Parameters
[in]bcThe container holding the gradient. The caller owns the pointed container.
[in]idThe ID of the gradient within the container.

◆ GetChecksum()

UInt32 GetChecksum ( ) const

Gets a checksum of the whole gradient state, including the knots, colors and interpolation type.

Returns
The checksum.

◆ GetGradient()

void GetGradient ( maxon::Gradient &  gradient) const

Gets the internal gradient.

◆ SetGradient()

void SetGradient ( maxon::Gradient &  gradient)

Sets the internal gradient.