Parasol Framework
  • Gallery
  • API
  • Wiki
  • GitHub
    • Audio
    • Core
    • Display
    • Fluid
    • Font
    • Network
    • Vector
    • Audio
    • Sound
    • File
    • MetaClass
    • Module
    • StorageDevice
    • Task
    • Thread
    • Time
    • Compression
    • Config
    • Script
    • XML
    • Controller
    • BlurFX
    • ColourFX
    • CompositeFX
    • ConvolveFX
    • DisplacementFX
    • FilterEffect
    • FloodFX
    • ImageFX
    • LightingFX
    • MergeFX
    • MorphologyFX
    • OffsetFX
    • RemapFX
    • SourceFX
    • TurbulenceFX
    • WaveFunctionFX
    • Scintilla
    • ScintillaSearch
    • Bitmap
    • Clipboard
    • Display
    • Document
    • Font
    • Picture
    • Pointer
    • Surface
    • SVG
    • ClientSocket
    • HTTP
    • NetSocket
    • Proxy
    • Vector
    • VectorClip
    • VectorColour
    • VectorEllipse
    • VectorFilter
    • VectorGradient
    • VectorGroup
    • VectorImage
    • VectorPath
    • VectorPattern
    • VectorPolygon
    • VectorRectangle
    • VectorScene
    • VectorShape
    • VectorSpiral
    • VectorText
    • VectorTransition
    • VectorViewport
    • VectorWave

VectorGradient Class

Provides support for the filling and stroking of vectors with colour gradients.

The VectorGradient class is used by Vector painting algorithms to fill and stroke vectors with gradients. This is achieved by initialising a VectorGradient object with the desired settings and then registering it with a VectorScene via the VectorScene⇒AddDef() method.

Any vector within the target scene will be able to utilise the gradient for filling or stroking by referencing its name through the Vector⇒Fill and Vector⇒Stroke fields. For instance 'url(#redgradient)'.

It is strongly recommended that the VectorGradient is owned by the VectorScene that is handling the definition. This will ensure that the VectorGradient is de-allocated when the scene is destroyed.

Structure

The VectorGradient class consists of the following fields:

Access
NameTypeComment
  CenterXDOUBLEThe horizontal center point of the gradient.

The (CenterX, CenterY) coordinates define the center point of the gradient. The center point will only be used if the gradient type requires it (such as the radial type). By default, the center point is set to 50%.

  CenterYDOUBLEThe vertical center point of the gradient.

The (CenterX, CenterY) coordinates define the center point of the gradient. The center point will only be used if the gradient type requires it (such as the radial type). By default, the center point is set to 50%.

  ColourFLOAT []The default background colour to use when clipping is enabled.

The colour value in this field is applicable only when a gradient is in clip-mode - by specifying the VSPREAD::CLIP flag in SpreadMethod. By default, this field has an alpha value of 0 to ensure that nothing is drawn outside the initial bounds of the gradient. Setting any other colour value here will otherwise fill-in those areas.

The Colour value is defined in floating-point RGBA format, using a range of 0 - 1.0 per component.

  ColourMapSTRINGAssigns a pre-defined colourmap to the gradient.

An alternative to defining colour Stops in a gradient is available in the form of named colourmaps. Declaring a colourmap in this field will automatically populate the gradient with the colours defined in the map.

We currently support the following established colourmaps from the matplotlib and seaborn projects: cmap:crest, cmap:flare, cmap:icefire, cmap:inferno, cmap:magma, cmap:mako, cmap:plasma, cmap:rocket, cmap:viridis.

The use of colourmaps and custom stops are mutually exclusive.

  ColourSpaceVCSDefines the colour space to use when interpolating gradient colours.

By default, gradients are rendered using the standard RGB colour space and alpha blending rules. Changing the colour space to LINEAR_RGB will force the renderer to automatically convert sRGB values to linear RGB when blending.

NameDescription
VCS::INHERITInherit the colour space option from the parent vector.
VCS::LINEAR_RGBLinear RGB is the default colour space for SVG and produces the best results.
VCS::SRGBThe default colour-space is sRGB, recommended for its speed.
  FlagsVGFDimension flags are stored here.

Dimension flags that indicate whether field values are fixed or scaled are defined here.

NameDescription
VGF::CONTAIN_FOCALContain the FX,FY point to the base radius.
VGF::FIXED_CXCX is fixed
VGF::FIXED_CYCY is fixed
VGF::FIXED_FOCAL_RADIUSFocal radius is fixed
VGF::FIXED_FXFX is fixed
VGF::FIXED_FYFY is fixed
VGF::FIXED_RADIUSRadius is fixed
VGF::FIXED_X1X1 is fixed
VGF::FIXED_X2X2 is fixed
VGF::FIXED_Y1Y1 is fixed
VGF::FIXED_Y2Y2 is fixed
VGF::SCALED_CXCX is scaled
VGF::SCALED_CYCY is scaled
VGF::SCALED_FOCAL_RADIUSFocal radius is scaled
VGF::SCALED_FXFX is scaled
VGF::SCALED_FYFY is scaled
VGF::SCALED_RADIUSRadius is scaled
VGF::SCALED_X1X1 is scaled
VGF::SCALED_X2X2 is scaled
VGF::SCALED_Y1Y1 is scaled
VGF::SCALED_Y2Y2 is scaled
  FocalRadiusDOUBLEThe size of the focal radius for radial gradients.

If a radial gradient has a defined focal point (by setting FocalX and FocalY) then the FocalRadius can be used to adjust the size of the focal area. The default of zero ensures that the focal area matches that defined by Radius, which is the standard maintained by SVG.

The FocalRadius value has no effect if the gradient is linear.

  FocalXDOUBLEThe horizontal focal point for radial gradients.

The (FocalX, FocalY) coordinates define the focal point for radial gradients. If left undefined, the focal point will match the center of the gradient.

  FocalYDOUBLEThe vertical focal point for radial gradients.

The (FocalX, FocalY) coordinates define the focal point for radial gradients. If left undefined, the focal point will match the center of the gradient.

  IDSTRINGString identifier for a vector.

The ID field is provided for the purpose of SVG support. Where possible, we recommend that you use the existing object name and automatically assigned ID's for identifiers.

  MatricesAPTRA linked list of transform matrices that have been applied to the gradient.

All transforms that have been applied to the gradient can be read from the Matrices field. Each transform is represented by a VectorMatrix structure, and are linked in the order in which they were applied to the gradient.

FieldTypeDescription
Nextstruct VectorMatrix *The next transform in the list.
VectorobjVector *The vector associated with the transform.
ScaleXDOUBLEMatrix value A
ShearYDOUBLEMatrix value B
ShearXDOUBLEMatrix value C
ScaleYDOUBLEMatrix value D
TranslateXDOUBLEMatrix value E
TranslateYDOUBLEMatrix value F
TagINTAn optional tag value defined by the client for matrix identification.
  NumericIDINTA unique identifier for the vector.

This field assigns a numeric ID to a vector. Alternatively it can also reflect a case-sensitive hash of the ID field if that has been defined previously.

If NumericID is set by the client, then any value in ID will be immediately cleared.

  RadiusDOUBLEThe radius of the gradient.

The radius of the gradient can be defined as a fixed unit or scaled relative to its container. A default radius of 50% (0.5) applies if this field is not set.

The Radius value has no effect if the gradient is linear.

  ResolutionDOUBLEAffects the rate of change for colours in the gradient.

By default, the colours generated for a gradient will be spaced for a smooth transition between stops that maximise resolution. The resolution can be reduced by setting the Resolution value to a fraction between 0 and 1.0.

This results in the colour values being averaged to a single value for every block of n colours, where n is the value 1 / (1 - Resolution).

Resolution is at its maximum when this value is set to 1 (the default).

  SpreadMethodVSPREADDetermines the rendering behaviour to use when gradient colours are cycled.

SpreadMethod determines what happens when the first cycle of gradient colours is exhausted and needs to begin again. The default setting is VSPREAD::PAD.

NameDescription
VSPREAD::CLIPDo not scale the graphic. Clip it if it extends past imposed boundaries.
VSPREAD::PADScale the graphic to the object bounds.
VSPREAD::REFLECTTile the graphic, reflecting the image alternately on the X and Y axis.
VSPREAD::REFLECT_XTile the graphic, reflecting the image alternately on the X axis only.
VSPREAD::REFLECT_YTile the graphic, reflecting the image alternately on the Y axis only.
VSPREAD::REPEATTile the graphic repeatedly.
VSPREAD::UNDEFINEDEither the default setting will be applied or the setting will be inherited from a parent object.
  StopsSTRUCT []Defines the colours to use for the gradient.

The colours that will be used for drawing a gradient are defined by the Stops array. At least two stops are required to define a start and end point for interpolating the gradient colours.

  TotalStopsINTTotal number of stops defined in the Stops array.

This read-only field indicates the total number of stops that have been defined in the Stops array.

  TransformSTRINGApplies a transform to the gradient.

A transform can be applied to the gradient by setting this field with an SVG compliant transform string.

  TypeVGTSpecifies the type of gradient (e.g. RADIAL, LINEAR)

The type of the gradient to be drawn is specified here.

NameDescription
VGT::CONICThe conic gradient is a variant on the radial type, whereby the colour values are drawn as a line that revolves around the cone's center point.
VGT::CONTOURContoured gradients follow the contours of the vector path in which they are rendered.
VGT::DIAMONDA diamond gradient is drawn as a square emanating from the center point.
VGT::LINEARA linear gradient is drawn from (X1, Y1) to (X2, Y2).
VGT::RADIALA radial gradient is drawn from CenterX, CenterY to Radius. An optional focal point can be expressed with FX and FY.
  UnitsVUNITDefines the coordinate system for X1, Y1, X2 and Y2.

The default coordinate system for gradients is BOUNDING_BOX, which positions the gradient around the vector that references it. The alternative is USERSPACE, which positions the gradient scaled to the current viewport.

NameDescription
VUNIT::BOUNDING_BOXCoordinates are scaled to the object's bounding box.
VUNIT::UNDEFINEDEither the default setting will be applied or the setting will be inherited from a parent object.
VUNIT::USERSPACECoordinates are scaled to the current viewport.
  X1DOUBLEInitial X coordinate for the gradient.

For linear gradients, the (X1, Y1) field values define the starting coordinate for mapping linear gradients. The gradient will be drawn from (X1, Y1) to (X2, Y2). Coordinate values can be expressed as units that are scaled to the target space.

For contour gradients, X1 is used as the floor for the gradient colour values and X2 acts as a multiplier. X1 has a range of 0 < X1 < X2 and X2 has a range of .01 < X2 < 10.

  X2DOUBLEFinal X coordinate for the gradient.

For linear gradients, the (X1, Y1) field values define the starting coordinate for mapping linear gradients. The gradient will be drawn from (X1, Y1) to (X2, Y2). Coordinate values can be expressed as units that are scaled to the target space.

For contour gradients, X1 is used as the floor for the gradient colour values and X2 acts as a multiplier. X1 has a range of 0 < X1 < X2 and X2 has a range of .01 < X2 < 10.

  Y1DOUBLEInitial Y coordinate for the gradient.

The (X1, Y1) field values define the starting coordinate for mapping linear gradients. Other gradient types ignore these values. The gradient will be drawn from (X1, Y1) to (X2, Y2).

Coordinate values can also be expressed as units that are scaled to the target space.

  Y2DOUBLEFinal Y coordinate for the gradient.

The (X2, Y2) field values define the end coordinate for mapping linear gradients. Other gradient types ignore these values. The gradient will be drawn from (X1, Y1) to (X2, Y2).

Coordinate values can also be expressed as units that are scaled to the target space.

VectorGradient class documentation © Paul Manias © 2010-2025

VCS Type

Colour space options.

NameDescription
VCS::INHERITInherit the colour space option from the parent vector.
VCS::LINEAR_RGBLinear RGB is the default colour space for SVG and produces the best results.
VCS::SRGBThe default colour-space is sRGB, recommended for its speed.
VectorGradient module documentation © Paul Manias © 2010-2025

VGF Type

Gradient flags

NameDescription
VGF::CONTAIN_FOCALContain the FX,FY point to the base radius.
VGF::FIXED_CXCX is fixed
VGF::FIXED_CYCY is fixed
VGF::FIXED_FOCAL_RADIUSFocal radius is fixed
VGF::FIXED_FXFX is fixed
VGF::FIXED_FYFY is fixed
VGF::FIXED_RADIUSRadius is fixed
VGF::FIXED_X1X1 is fixed
VGF::FIXED_X2X2 is fixed
VGF::FIXED_Y1Y1 is fixed
VGF::FIXED_Y2Y2 is fixed
VGF::SCALED_CXCX is scaled
VGF::SCALED_CYCY is scaled
VGF::SCALED_FOCAL_RADIUSFocal radius is scaled
VGF::SCALED_FXFX is scaled
VGF::SCALED_FYFY is scaled
VGF::SCALED_RADIUSRadius is scaled
VGF::SCALED_X1X1 is scaled
VGF::SCALED_X2X2 is scaled
VGF::SCALED_Y1Y1 is scaled
VGF::SCALED_Y2Y2 is scaled
VectorGradient module documentation © Paul Manias © 2010-2025

VGT Type

VectorGradient options.

NameDescription
VGT::CONICThe conic gradient is a variant on the radial type, whereby the colour values are drawn as a line that revolves around the cone's center point.
VGT::CONTOURContoured gradients follow the contours of the vector path in which they are rendered.
VGT::DIAMONDA diamond gradient is drawn as a square emanating from the center point.
VGT::LINEARA linear gradient is drawn from (X1, Y1) to (X2, Y2).
VGT::RADIALA radial gradient is drawn from CenterX, CenterY to Radius. An optional focal point can be expressed with FX and FY.
VectorGradient module documentation © Paul Manias © 2010-2025

VSPREAD Type

Spread method options define the method to use for tiling filled graphics.

NameDescription
VSPREAD::CLIPDo not scale the graphic. Clip it if it extends past imposed boundaries.
VSPREAD::PADScale the graphic to the object bounds.
VSPREAD::REFLECTTile the graphic, reflecting the image alternately on the X and Y axis.
VSPREAD::REFLECT_XTile the graphic, reflecting the image alternately on the X axis only.
VSPREAD::REFLECT_YTile the graphic, reflecting the image alternately on the Y axis only.
VSPREAD::REPEATTile the graphic repeatedly.
VSPREAD::UNDEFINEDEither the default setting will be applied or the setting will be inherited from a parent object.
VectorGradient module documentation © Paul Manias © 2010-2025

VUNIT Type

NameDescription
VUNIT::BOUNDING_BOXCoordinates are scaled to the object's bounding box.
VUNIT::UNDEFINEDEither the default setting will be applied or the setting will be inherited from a parent object.
VUNIT::USERSPACECoordinates are scaled to the current viewport.
VectorGradient module documentation © Paul Manias © 2010-2025

VectorMatrix Structure

Vector transformation matrix.

FieldTypeDescription
Nextstruct VectorMatrix *The next transform in the list.
VectorobjVector *The vector associated with the transform.
ScaleXDOUBLEMatrix value A
ShearYDOUBLEMatrix value B
ShearXDOUBLEMatrix value C
ScaleYDOUBLEMatrix value D
TranslateXDOUBLEMatrix value E
TranslateYDOUBLEMatrix value F
TagINTAn optional tag value defined by the client for matrix identification.
VectorGradient class documentation © Paul Manias © 2010-2025