libSBML C API  5.18.0
GradientBase_t Class Reference

Detailed Description

render Abstract base class for linear and radial gradients.

The base class implements common structures to both gradient classes. Both gradients have an id attribute which is used to reference a gradient within other render extension constructs. The id of a gradient can be used to define the fill style of 2D objects like e.g. rectangles.

Further, both gradient classes have a ListOfGradientStops_t objects which holds the GradientStop_t objects that define the gradient and both classes have an attribute called spreadMethod which defines how a gradient is applied to an object.

Public Member Functions

int GradientBase_addGradientStop (GradientBase_t *gb, const GradientStop_t *gs)
 Adds a copy of the given GradientStop_t to this GradientBase_t. More...
 
GradientBase_tGradientBase_clone (const GradientBase_t *gb)
 Creates and returns a deep copy of this GradientBase_t object. More...
 
GradientStop_tGradientBase_createGradientStop (GradientBase_t *gb)
 Creates a new GradientStop_t object, adds it to this GradientBase_t object and returns the GradientStop_t object created. More...
 
GradientBase_tGradientBase_createLinearGradient (unsigned int level, unsigned int version, unsigned int pkgVersion)
 Creates a new LinearGradient_t (GradientBase_t) using the given SBML Level, Version and “render” package version. More...
 
GradientBase_tGradientBase_createRadialGradient (unsigned int level, unsigned int version, unsigned int pkgVersion)
 Creates a new RadialGradient_t (GradientBase_t) using the given SBML Level, Version and “render” package version. More...
 
void GradientBase_free (GradientBase_t *gb)
 Frees this GradientBase_t object. More...
 
GradientStop_tGradientBase_getGradientStop (GradientBase_t *gb, unsigned int n)
 Get a GradientStop_t from the GradientBase_t. More...
 
char * GradientBase_getId (const GradientBase_t *gb)
 Returns the value of the "id" attribute of this GradientBase_t. More...
 
ListOf_tGradientBase_getListOfGradientStops (GradientBase_t *gb)
 Returns a ListOf_t * containing GradientStop_t objects from this GradientBase_t. More...
 
char * GradientBase_getName (const GradientBase_t *gb)
 Returns the value of the "name" attribute of this GradientBase_t. More...
 
unsigned int GradientBase_getNumGradientStops (GradientBase_t *gb)
 Get the number of GradientStop_t objects in this GradientBase_t. More...
 
GradientSpreadMethod_t GradientBase_getSpreadMethod (const GradientBase_t *gb)
 Returns the value of the "spreadMethod" attribute of this GradientBase_t. More...
 
char * GradientBase_getSpreadMethodAsString (const GradientBase_t *gb)
 Returns the value of the "spreadMethod" attribute of this GradientBase_t. More...
 
int GradientBase_hasRequiredAttributes (const GradientBase_t *gb)
 Predicate returning 1 (true) if all the required attributes for this GradientBase_t object have been set. More...
 
int GradientBase_isLinearGradient (const GradientBase_t *gb)
 Predicate returning 1 if this GradientBase_t is of type LinearGradient_t. More...
 
int GradientBase_isRadialGradient (const GradientBase_t *gb)
 Predicate returning 1 if this GradientBase_t is of type RadialGradient_t. More...
 
int GradientBase_isSetId (const GradientBase_t *gb)
 Predicate returning 1 (true) if this GradientBase_t's "id" attribute is set. More...
 
int GradientBase_isSetName (const GradientBase_t *gb)
 Predicate returning 1 (true) if this GradientBase_t's "name" attribute is set. More...
 
int GradientBase_isSetSpreadMethod (const GradientBase_t *gb)
 Predicate returning 1 (true) if this GradientBase_t's "spreadMethod" attribute is set. More...
 
GradientStop_tGradientBase_removeGradientStop (GradientBase_t *gb, unsigned int n)
 Removes the nth GradientStop_t from this GradientBase_t and returns a pointer to it. More...
 
int GradientBase_setId (GradientBase_t *gb, const char *id)
 Sets the value of the "id" attribute of this GradientBase_t. More...
 
int GradientBase_setName (GradientBase_t *gb, const char *name)
 Sets the value of the "name" attribute of this GradientBase_t. More...
 
int GradientBase_setSpreadMethod (GradientBase_t *gb, GradientSpreadMethod_t spreadMethod)
 Sets the value of the "spreadMethod" attribute of this GradientBase_t. More...
 
int GradientBase_setSpreadMethodAsString (GradientBase_t *gb, const char *spreadMethod)
 Sets the value of the "spreadMethod" attribute of this GradientBase_t. More...
 
int GradientBase_unsetId (GradientBase_t *gb)
 Unsets the value of the "id" attribute of this GradientBase_t. More...
 
int GradientBase_unsetName (GradientBase_t *gb)
 Unsets the value of the "name" attribute of this GradientBase_t. More...
 
int GradientBase_unsetSpreadMethod (GradientBase_t *gb)
 Unsets the value of the "spreadMethod" attribute of this GradientBase_t. More...
 
GradientSpreadMethod_t GradientSpreadMethod_fromString (const char *code)
 Returns the GradientSpreadMethod_t enumeration corresponding to the given string or GRADIENT_SPREAD_METHOD_INVALID if there is no such match. More...
 
int GradientSpreadMethod_isValid (GradientSpreadMethod_t gsm)
 Predicate returning 1 (true) or 0 (false) depending on whether the given GradientSpreadMethod_t is valid. More...
 
int GradientSpreadMethod_isValidString (const char *code)
 Predicate returning 1 (true) or 0 (false) depending on whether the given string is a valid GradientSpreadMethod_t. More...
 
const char * GradientSpreadMethod_toString (GradientSpreadMethod_t gsm)
 Returns the string version of the provided GradientSpreadMethod_t enumeration. More...
 

Member Function Documentation

int GradientBase_addGradientStop ( GradientBase_t gb,
const GradientStop_t gs 
)

Adds a copy of the given GradientStop_t to this GradientBase_t.

Parameters
gbthe GradientBase_t structure to which the GradientStop_t should be added.
gsthe GradientStop_t object to add.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
GradientBase_t * GradientBase_clone ( const GradientBase_t gb)

Creates and returns a deep copy of this GradientBase_t object.

Parameters
gbthe GradientBase_t structure.
Returns
a (deep) copy of this GradientBase_t object.
Warning
The pointer that is returned by this function is owned by the caller, who is responsible for deleting it. Any changes made to the element will not be reflected in any resulting SBML document unless the element is added to an SBML Document. Even in this case, the element's deletion is still the responsibility of the caller with two exceptions: if it is used as the "disownedItem" in the ListOf_appendAndOwn() or ListOf_insertAndOwn() functions. All other functions in libsbml add a copy of the element, and do not transfer ownership of the pointer.
GradientStop_t * GradientBase_createGradientStop ( GradientBase_t gb)

Creates a new GradientStop_t object, adds it to this GradientBase_t object and returns the GradientStop_t object created.

Parameters
gbthe GradientBase_t structure to which the GradientStop_t should be added.
Returns
a new GradientStop_t object instance.
Note
The pointer that is returned by this function is not owned by the caller, but may be queried and modified. Any changes made will be reflected in any resulting SBML document containing the pointer's parent.
GradientBase_t * GradientBase_createLinearGradient ( unsigned int  level,
unsigned int  version,
unsigned int  pkgVersion 
)

Creates a new LinearGradient_t (GradientBase_t) using the given SBML Level, Version and “render” package version.

Parameters
levelan unsigned int, the SBML Level to assign to this GradientBase_t.
versionan unsigned int, the SBML Version to assign to this GradientBase_t.
pkgVersionan unsigned int, the SBML Render Version to assign to this GradientBase_t.
Note
Attempting to add an object to an SBMLDocument_t having a different combination of SBML Level, Version and XML namespaces than the object itself will result in an error at the time a caller attempts to make the addition. A parent object must have compatible Level, Version and XML namespaces. (Strictly speaking, a parent may also have more XML namespaces than a child, but the reverse is not permitted.) The restriction is necessary to ensure that an SBML model has a consistent overall structure. This requires callers to manage their objects carefully, but the benefit is increased flexibility in how models can be created by permitting callers to create objects bottom-up if desired. In situations where objects are not yet attached to parents (e.g., SBMLDocument_t), knowledge of the intented SBML Level and Version help libSBML determine such things as whether it is valid to assign a particular value to an attribute. For packages, this means that the parent object to which this package element is being added must have been created with the package namespace, or that the package namespace was added to it, even if that parent is not a package object itself.
Warning
The pointer that is returned by this function is owned by the caller, who is responsible for deleting it. Any changes made to the element will not be reflected in any resulting SBML document unless the element is added to an SBML Document. Even in this case, the element's deletion is still the responsibility of the caller with two exceptions: if it is used as the "disownedItem" in the ListOf_appendAndOwn() or ListOf_insertAndOwn() functions. All other functions in libsbml add a copy of the element, and do not transfer ownership of the pointer.
GradientBase_t * GradientBase_createRadialGradient ( unsigned int  level,
unsigned int  version,
unsigned int  pkgVersion 
)

Creates a new RadialGradient_t (GradientBase_t) using the given SBML Level, Version and “render” package version.

Parameters
levelan unsigned int, the SBML Level to assign to this GradientBase_t.
versionan unsigned int, the SBML Version to assign to this GradientBase_t.
pkgVersionan unsigned int, the SBML Render Version to assign to this GradientBase_t.
Note
Attempting to add an object to an SBMLDocument_t having a different combination of SBML Level, Version and XML namespaces than the object itself will result in an error at the time a caller attempts to make the addition. A parent object must have compatible Level, Version and XML namespaces. (Strictly speaking, a parent may also have more XML namespaces than a child, but the reverse is not permitted.) The restriction is necessary to ensure that an SBML model has a consistent overall structure. This requires callers to manage their objects carefully, but the benefit is increased flexibility in how models can be created by permitting callers to create objects bottom-up if desired. In situations where objects are not yet attached to parents (e.g., SBMLDocument_t), knowledge of the intented SBML Level and Version help libSBML determine such things as whether it is valid to assign a particular value to an attribute. For packages, this means that the parent object to which this package element is being added must have been created with the package namespace, or that the package namespace was added to it, even if that parent is not a package object itself.
Warning
The pointer that is returned by this function is owned by the caller, who is responsible for deleting it. Any changes made to the element will not be reflected in any resulting SBML document unless the element is added to an SBML Document. Even in this case, the element's deletion is still the responsibility of the caller with two exceptions: if it is used as the "disownedItem" in the ListOf_appendAndOwn() or ListOf_insertAndOwn() functions. All other functions in libsbml add a copy of the element, and do not transfer ownership of the pointer.
void GradientBase_free ( GradientBase_t gb)

Frees this GradientBase_t object.

Parameters
gbthe GradientBase_t structure.
GradientStop_t * GradientBase_getGradientStop ( GradientBase_t gb,
unsigned int  n 
)

Get a GradientStop_t from the GradientBase_t.

Parameters
gbthe GradientBase_t structure to search.
nan unsigned int representing the index of the GradientStop_t to retrieve.
Returns
the nth GradientStop_t in the ListOfGradientStops_t within this GradientBase_t. If the index n is invalid, NULL is returned.
Note
The pointer that is returned by this function is not owned by the caller, but may be queried and modified. Any changes made will be reflected in any resulting SBML document containing the pointer's parent.
char * GradientBase_getId ( const GradientBase_t gb)

Returns the value of the "id" attribute of this GradientBase_t.

Parameters
gbthe GradientBase_t structure whose id is sought.
Returns
the value of the "id" attribute of this GradientBase_t as a pointer to a string.
Warning
The string returned by this function is owned by the caller, who is responsible for deleting it. Any changes made to the string will not be reflected in any resulting SBML document unless the string is added to an SBML Document. Even in this case, the string should be deleted, as adding a string to an SBML Document adds a copy of the string, and does not transfer ownership of that string.
ListOf_t * GradientBase_getListOfGradientStops ( GradientBase_t gb)

Returns a ListOf_t * containing GradientStop_t objects from this GradientBase_t.

Parameters
gbthe GradientBase_t structure whose ListOfGradientStops_t is sought.
Returns
the ListOfGradientStops_t from this GradientBase_t as a ListOf_t *.
Note
The pointer that is returned by this function is not owned by the caller, but may be queried and modified. Any changes made will be reflected in any resulting SBML document containing the pointer's parent.
See also
GradientBase_addGradientStop()
GradientBase_createGradientStop()
GradientBase_getGradientStopById()
GradientBase_getGradientStop()
GradientBase_getNumGradientStops()
GradientBase_removeGradientStopById()
GradientBase_removeGradientStop()
char * GradientBase_getName ( const GradientBase_t gb)

Returns the value of the "name" attribute of this GradientBase_t.

Parameters
gbthe GradientBase_t structure whose name is sought.
Returns
the value of the "name" attribute of this GradientBase_t as a pointer to a string.
Warning
The string returned by this function is owned by the caller, who is responsible for deleting it. Any changes made to the string will not be reflected in any resulting SBML document unless the string is added to an SBML Document. Even in this case, the string should be deleted, as adding a string to an SBML Document adds a copy of the string, and does not transfer ownership of that string.
unsigned int GradientBase_getNumGradientStops ( GradientBase_t gb)

Get the number of GradientStop_t objects in this GradientBase_t.

Parameters
gbthe GradientBase_t structure to query.
Returns
the number of GradientStop_t objects in this GradientBase_t.
GradientSpreadMethod_t GradientBase_getSpreadMethod ( const GradientBase_t gb)

Returns the value of the "spreadMethod" attribute of this GradientBase_t.

Parameters
gbthe GradientBase_t structure whose spreadMethod is sought.
Returns
the value of the "spreadMethod" attribute of this GradientBase_t as a GradientSpreadMethod_t.
The attribute "spreadMethod" on a GradientBase_t object is used by GradientBase_t elements to decide how gradients propagate over the whole element they are applied to. The following are the allowable values for "spreadMethod":
  • "pad", the gradient color at the endpoint of the vector defines how the gradient is continued beyond that point (default value).

  • "reflect", the gradient continues from end to start and then from start to end again and again.

  • "repeat", the gradient pattern is repeated from start to end over and over again.

The value is drawn from the enumeration GradientSpreadMethod_t. The possible values returned by this method are:
char * GradientBase_getSpreadMethodAsString ( const GradientBase_t gb)

Returns the value of the "spreadMethod" attribute of this GradientBase_t.

Parameters
gbthe GradientBase_t structure whose spreadMethod is sought.
Returns
the value of the "spreadMethod" attribute of this GradientBase_t as a const char *.
Note
The string returned by this function is a pointer to a string literal defined in the libSBML library, and may not be modified or deleted.
The attribute "spreadMethod" on a GradientBase_t object is used by GradientBase_t elements to decide how gradients propagate over the whole element they are applied to. The following are the allowable values for "spreadMethod":
  • "pad", the gradient color at the endpoint of the vector defines how the gradient is continued beyond that point (default value).

  • "reflect", the gradient continues from end to start and then from start to end again and again.

  • "repeat", the gradient pattern is repeated from start to end over and over again.

The possible values returned by this method are:
  • "pad"
  • "reflect"
  • "repeat"
  • "invalid"
int GradientBase_hasRequiredAttributes ( const GradientBase_t gb)

Predicate returning 1 (true) if all the required attributes for this GradientBase_t object have been set.

Parameters
gbthe GradientBase_t structure.
Returns
1 (true) to indicate that all the required attributes of this GradientBase_t have been set, otherwise 0 (false) is returned.
Note
The required attributes for the GradientBase_t object are:
  • "id"
int GradientBase_isLinearGradient ( const GradientBase_t gb)

Predicate returning 1 if this GradientBase_t is of type LinearGradient_t.

Parameters
gbthe GradientBase_t structure.
Returns
1 if this GradientBase_t is of type LinearGradient_t, 0 otherwise
int GradientBase_isRadialGradient ( const GradientBase_t gb)

Predicate returning 1 if this GradientBase_t is of type RadialGradient_t.

Parameters
gbthe GradientBase_t structure.
Returns
1 if this GradientBase_t is of type RadialGradient_t, 0 otherwise
int GradientBase_isSetId ( const GradientBase_t gb)

Predicate returning 1 (true) if this GradientBase_t's "id" attribute is set.

Parameters
gbthe GradientBase_t structure.
Returns
1 (true) if this GradientBase_t's "id" attribute has been set, otherwise 0 (false) is returned.
int GradientBase_isSetName ( const GradientBase_t gb)

Predicate returning 1 (true) if this GradientBase_t's "name" attribute is set.

Parameters
gbthe GradientBase_t structure.
Returns
1 (true) if this GradientBase_t's "name" attribute has been set, otherwise 0 (false) is returned.
int GradientBase_isSetSpreadMethod ( const GradientBase_t gb)

Predicate returning 1 (true) if this GradientBase_t's "spreadMethod" attribute is set.

Parameters
gbthe GradientBase_t structure.
Returns
1 (true) if this GradientBase_t's "spreadMethod" attribute has been set, otherwise 0 (false) is returned.
The attribute "spreadMethod" on a GradientBase_t object is used by GradientBase_t elements to decide how gradients propagate over the whole element they are applied to. The following are the allowable values for "spreadMethod":
  • "pad", the gradient color at the endpoint of the vector defines how the gradient is continued beyond that point (default value).

  • "reflect", the gradient continues from end to start and then from start to end again and again.

  • "repeat", the gradient pattern is repeated from start to end over and over again.

GradientStop_t * GradientBase_removeGradientStop ( GradientBase_t gb,
unsigned int  n 
)

Removes the nth GradientStop_t from this GradientBase_t and returns a pointer to it.

Parameters
gbthe GradientBase_t structure to search.
nan unsigned int representing the index of the GradientStop_t to remove.
Returns
a pointer to the nth GradientStop_t in this GradientBase_t.
Warning
The pointer that is returned by this function is owned by the caller, who is responsible for deleting it. Any changes made to the element will not be reflected in any resulting SBML document unless the element is added to an SBML Document. Even in this case, the element's deletion is still the responsibility of the caller with two exceptions: if it is used as the "disownedItem" in the ListOf_appendAndOwn() or ListOf_insertAndOwn() functions. All other functions in libsbml add a copy of the element, and do not transfer ownership of the pointer.
int GradientBase_setId ( GradientBase_t gb,
const char *  id 
)

Sets the value of the "id" attribute of this GradientBase_t.

Parameters
gbthe GradientBase_t structure.
idconst char * value of the "id" attribute to be set.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are: Calling this function with id = NULL or an empty string is equivalent to calling GradientBase_unsetId().
int GradientBase_setName ( GradientBase_t gb,
const char *  name 
)

Sets the value of the "name" attribute of this GradientBase_t.

Parameters
gbthe GradientBase_t structure.
nameconst char * value of the "name" attribute to be set.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are: Calling this function with name = NULL or an empty string is equivalent to calling GradientBase_unsetName().
int GradientBase_setSpreadMethod ( GradientBase_t gb,
GradientSpreadMethod_t  spreadMethod 
)

Sets the value of the "spreadMethod" attribute of this GradientBase_t.

Parameters
gbthe GradientBase_t structure.
spreadMethodGradientSpreadMethod_t value of the "spreadMethod" attribute to be set.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
The attribute "spreadMethod" on a GradientBase_t object is used by GradientBase_t elements to decide how gradients propagate over the whole element they are applied to. The following are the allowable values for "spreadMethod":
  • "pad", the gradient color at the endpoint of the vector defines how the gradient is continued beyond that point (default value).

  • "reflect", the gradient continues from end to start and then from start to end again and again.

  • "repeat", the gradient pattern is repeated from start to end over and over again.

int GradientBase_setSpreadMethodAsString ( GradientBase_t gb,
const char *  spreadMethod 
)

Sets the value of the "spreadMethod" attribute of this GradientBase_t.

Parameters
gbthe GradientBase_t structure.
spreadMethodconst char * of the "spreadMethod" attribute to be set.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
The attribute "spreadMethod" on a GradientBase_t object is used by GradientBase_t elements to decide how gradients propagate over the whole element they are applied to. The following are the allowable values for "spreadMethod":
  • "pad", the gradient color at the endpoint of the vector defines how the gradient is continued beyond that point (default value).

  • "reflect", the gradient continues from end to start and then from start to end again and again.

  • "repeat", the gradient pattern is repeated from start to end over and over again.

int GradientBase_unsetId ( GradientBase_t gb)

Unsets the value of the "id" attribute of this GradientBase_t.

Parameters
gbthe GradientBase_t structure.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
int GradientBase_unsetName ( GradientBase_t gb)

Unsets the value of the "name" attribute of this GradientBase_t.

Parameters
gbthe GradientBase_t structure.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
int GradientBase_unsetSpreadMethod ( GradientBase_t gb)

Unsets the value of the "spreadMethod" attribute of this GradientBase_t.

Parameters
gbthe GradientBase_t structure.
Returns
integer value indicating success/failure of the function. The value is drawn from the enumeration OperationReturnValues_t. The possible values returned by this function are:
The attribute "spreadMethod" on a GradientBase_t object is used by GradientBase_t elements to decide how gradients propagate over the whole element they are applied to. The following are the allowable values for "spreadMethod":
  • "pad", the gradient color at the endpoint of the vector defines how the gradient is continued beyond that point (default value).

  • "reflect", the gradient continues from end to start and then from start to end again and again.

  • "repeat", the gradient pattern is repeated from start to end over and over again.

GradientSpreadMethod_t GradientSpreadMethod_fromString ( const char *  code)

Returns the GradientSpreadMethod_t enumeration corresponding to the given string or GRADIENT_SPREAD_METHOD_INVALID if there is no such match.

Parameters
codethe string to convert to a GradientSpreadMethod_t.
Returns
the corresponding GradientSpreadMethod_t or GRADIENT_SPREAD_METHOD_INVALID if no match is found.
Note
The matching is case-sensitive: "pad" will return GRADIENT_SPREADMETHOD_PAD, but "Pad" will return GRADIENT_SPREAD_METHOD_INVALID.
int GradientSpreadMethod_isValid ( GradientSpreadMethod_t  gsm)

Predicate returning 1 (true) or 0 (false) depending on whether the given GradientSpreadMethod_t is valid.

Parameters
gsmthe GradientSpreadMethod_t enumeration to query.
Returns
1 (true) if the GradientSpreadMethod_t is GRADIENT_SPREADMETHOD_PAD, GRADIENT_SPREADMETHOD_REFLECT, or GRADIENT_SPREADMETHOD_REPEAT; 0 (false) otherwise (including GRADIENT_SPREAD_METHOD_INVALID).
int GradientSpreadMethod_isValidString ( const char *  code)

Predicate returning 1 (true) or 0 (false) depending on whether the given string is a valid GradientSpreadMethod_t.

Parameters
codethe string to query.
Returns
1 (true) if the string is "pad", "reflect", or "repeat"; 0 (false) otherwise.
Note
The matching is case-sensitive: "pad" will return 1 (true), but "Pad" will return 0 (false).
const char * GradientSpreadMethod_toString ( GradientSpreadMethod_t  gsm)

Returns the string version of the provided GradientSpreadMethod_t enumeration.

Parameters
gsmthe GradientSpreadMethod_t enumeration value to convert.
Returns
A string corresponding to the given type: "pad", "reflect", "repeat", "invalid" or "(Unknown GradientSpreadMethod value)" if the value is an unknown enumeration value.
Note
The string returned by this function is a pointer to a string literal defined in the libSBML library, and may not be modified or deleted.