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

GradientDiffusion Class

Diffusion curves paint server [BETA].

This class is in beta and is not yet fully supported. It is available for experimentation and feedback.

GradientDiffusion implements diffusion curves, a vector representation for smooth-shaded images (Orzan et al., SIGGRAPH 2008). The client supplies a sparse set of cubic Bezier curves through Curves, with an independent colour assigned to each side of every curve. The colours diffuse outward from the curves until they meet, producing smooth, organic shading across the fill region; each curve acts simultaneously as a colour source and as a barrier that prevents the colours of other curves from bleeding across it.

"Left" and "right" are relative to the direction of travel from the curve's start point to its end point, i.e. the left side is the side pointed to by the normal (-dy, dx). Colours are interpolated linearly along the length of each curve from its start colour to its end colour. Multi-segment curves are expressed as consecutive records that share endpoints and colours.

The diffusion is evaluated by relaxing a Laplace equation over a cached raster grid. The grid is re-solved only when the curve set or solve parameters change, so static gradients render at full speed after the first frame. The Gradient⇒Resolution field scales the solve grid's resolution: at 0 the longest axis receives 128 texels, rising to 512 texels at 1.0.

The inherited colour-ramp fields Stops, ColourMap, SpreadMethod and Colour are not supported by this class. All colour information is supplied through Curves.

Structure

The GradientDiffusion class consists of the following fields:

Access
NameTypeComment
 Curveskt::vector<DiffusionCurveRecord>Defines the diffusion curves and their per-side colours.

The Curves array defines one or more diffusion curves. Each DiffusionCurveRecord carries the cubic Bezier geometry of one curve segment in its Curve member, plus a start and end colour for each side of the curve: LeftStart, LeftEnd, RightStart and RightEnd. Colours are interpolated linearly along the curve's arc length, and the left side is the side pointed to by the normal (-dy, dx) when travelling from the curve's start to its end.

The coordinate system for curve positions is determined by Gradient⇒Units. Under BOUNDING_BOX, normalised curve 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 and the colour field is solved over the target path's bounds.

Colour components are clamped to the range 0 - 1.0 at assignment. Alpha participates in the diffusion, so transparent constraints are legal. Degenerate (zero-length) curve segments are skipped during rendering.

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

DiffusionCurveRecord Structure

Describes one curve for the GradientDiffusion Curves field.

FieldTypeDescription
Curvestruct MeshControlCubic Bezier geometry for this curve segment.
LeftStartstruct FRGBColour on the left side at the start of the curve.
LeftEndstruct FRGBColour on the left side at the end of the curve.
RightStartstruct FRGBColour on the right side at the start of the curve.
RightEndstruct FRGBColour on the right side at the end of the curve.
GradientDiffusion class documentation © Paul Manias © 2010-2026