Kōtuku
  • Gallery
  • API
  • Wiki
  • GitHub
    • Audio
    • Config
    • Core
    • Display
    • Document
    • Font
    • HTTP
    • Network
    • Regex
    • SVG
    • Tiri
    • Vector
    • XML
    • XQuery
    • XRandR
      • Audio
      • MP3
      • Sound
      • File
      • MetaClass
      • Module
      • StorageDevice
      • Task
      • Thread
      • Time
      • Compression
      • CompressedStream
      • Config
      • LZMAStream
      • Script
      • Tiri
      • XML
      • XQuery
      • Controller
      • BlurFX
      • ColourFX
      • CompositeFX
      • ConvolveFX
      • DisplacementFX
      • FilterEffect
      • FloodFX
      • ImageFX
      • LightingFX
      • MergeFX
      • MorphologyFX
      • OffsetFX
      • RemapFX
      • SourceFX
      • TurbulenceFX
      • WaveFunctionFX
      • Scintilla
      • Bitmap
      • Clipboard
      • Display
      • Document
      • Font
      • Image
      • Pointer
      • Surface
      • SVG
      • ClientSocket
      • HTTP
      • NetClient
      • NetLookup
      • NetServer
      • NetSocket
      • Proxy
      • Gradient
      • GradientConic
      • GradientContour
      • GradientDiamond
      • GradientDiffusion
      • GradientDistal
      • GradientGouraud
      • GradientLinear
      • GradientMesh
      • GradientRadial
      • GradientVoronoi
      • Vector
      • VectorClip
      • VectorColour
      • VectorEllipse
      • VectorFilter
      • VectorGradient
      • VectorGroup
      • VectorImage
      • VectorPath
      • VectorPattern
      • VectorPolygon
      • VectorRectangle
      • VectorScene
      • VectorShape
      • VectorSpiral
      • VectorText
      • VectorTransition
      • VectorViewport
      • VectorWave
      • Linux Builds
      • Windows Builds
      • Customising Your Build
      • Kōtuku Objects
      • Kōtuku In Depth
      • Kōtuku Design Patterns
      • Coding With AI
      • Regex Manual
      • XML Comparisons
      • Tiri Reference Manual
      • Config API
      • Defer Syntax
      • GUI API
      • HTTP Server API
      • I/O API
      • JSON API
      • OAuth API
      • Options API
      • Proxy Server API
      • Tempus API
      • URL API
      • VFX API
      • Widgets
      • RIPL Reference Manual
      • Origo
      • Flute / Unit Testing
      • Tuku
      • Embedded Document Format
      • TDL Reference Manual
      • TDL Tools
      • Action Reference Manual
      • System Error Codes

GradientMesh Class

Bilinear Coons patch mesh gradient paint server.

GradientMesh interpolates colour across a grid of curved patches. Each patch is bounded by four cubic Bezier edges and carries one colour at each corner. Rendering tessellates the patches into Gouraud triangles, so colour follows the patch geometry rather than a one-dimensional colour ramp. Corner colours are blended bilinearly by default; setting Mode to BICUBIC selects smooth bicubic colour interpolation across the patch grid instead.

The inherited colour-ramp fields Stops, ColourMap, SpreadMethod and Colour are not supported by this class. Patch geometry and corner colours are supplied through Patches.

When a mesh is exported to SVG, valid Rows and Columns metadata is preserved through the standard shared-edge meshrow syntax. A mesh without valid row metadata (e.g. a non-rectangular grid) is flattened to a single row on export; every patch survives intact, with patches that do not share an edge with their predecessor written as independent patches, but the original row structure is not retained.

Structure

The GradientMesh class consists of the following fields:

Access
NameTypeComment
 ColumnsINTThe number of columns represented by the flat Patches array.

Columns stores the column count for the mesh grid while Patches remains a flat row-major array. The row and column counts must multiply to the number of patch records when both dimensions and patches are present.

 ModeGMTChooses the interpolation mode for the mesh gradient.

By default, corner colours are interpolated bilinearly across each patch, which can leave a visible star or cross artefact where patch corners meet. Opting for the BICUBIC mode switches to bicubic colour interpolation: colour derivatives are estimated at each grid corner from the neighbouring patch colours, giving smooth colour transitions across patch seams. This matches the type="bicubic" mesh gradient mode of the SVG proposal (Inkscape's "smooth colors" option). Patch geometry is unaffected; only the colour surface changes.

The setting is a rendering mode and is retained when Patches is reassigned.

NameDescription
GMT::BICUBICUse bicubic interpolation for the patch colours.
GMT::LINEARUse linear interpolation for the patch colours.
GMT::UNDEFINEDEither the default setting will be applied or the setting will be inherited from a parent object.
 Patcheskt::vector<MeshPatchRecord>Defines the Coons patches for a mesh gradient.

The Patches array defines one or more bilinear Coons patches. Each MeshPatchRecord contains four cubic Bezier edges in clockwise order (Top, Right, Bottom, Left) plus the top-left, top-right, bottom-right and bottom-left corner colours.

The coordinate system for patch positions is determined by Gradient⇒Units. Under BOUNDING_BOX, normalised patch coordinates in the range 0 - 1.0 are scaled into the target path's bounds. Under USERSPACE, positions are taken directly in the viewport's coordinate system.

Assigning an empty array clears the mesh entirely, including the Rows and Columns metadata.

 RowsINTThe number of rows represented by the flat Patches array.

Rows stores the row count for the mesh grid while Patches remains a flat row-major array. When valid row and column metadata is supplied, SVG export can preserve standard meshgradient shared-edge syntax across multiple rows. If no metadata is supplied, assigning Patches defaults to a single-row mesh for simple programmatic use.

 XMLDefSTRINGReturns an SVG compliant XML string that describes the effect.
GradientMesh class documentation © Paul Manias © 2010-2026

GMT Type

Available modes for the GradientMesh class.

NameDescription
GMT::BICUBICUse bicubic interpolation for the patch colours.
GMT::LINEARUse linear interpolation for the patch colours.
GMT::UNDEFINEDEither the default setting will be applied or the setting will be inherited from a parent object.
GradientMesh module documentation © Paul Manias © 2010-2026

MeshPatchRecord Structure

Describes one bilinear Coons patch for the GradientMesh Patches field.

FieldTypeDescription
Topstruct MeshControlTop edge
Rightstruct MeshControlRight edge
Bottomstruct MeshControlBottom edge
Leftstruct MeshControlLeft edge
TopLeftstruct FRGBColour assigned to the top-left patch corner.
TopRightstruct FRGBColour assigned to the top-right patch corner.
BottomRightstruct FRGBColour assigned to the bottom-right patch corner.
BottomLeftstruct FRGBColour assigned to the bottom-left patch corner.
GradientMesh class documentation © Paul Manias © 2010-2026