Skip to content
Member Filters
Show Inherited
Show Protected
Show abstract
GR32_ColorGradients🞂TVoronoiSamplerClass

TVoronoiSampler

A sparse point Voronoi tesselation sampler.

Inheritance:TObject 🞂 TPersistent 🞂 TNotifiablePersistent 🞂 TCustomSampler 🞂 TCustomSparsePointGradientSampler 🞂 TCustomArbitrarySparsePointGradientSampler 🞂 TVoronoiSampler

Declaration ​

pascal
TVoronoiSampler = class(TCustomArbitrarySparsePointGradientSampler)

Description ​

TVoronoiSampler samples discrete or cell-bounded color regions using Voronoi diagram metric distance partitioning.

Although the Voronoi tesselation can be used as a sparse point color gradient interpolator, it is actually rather a tesselation to discrete solid colors than a color gradient interpolation. However, it might still be relevant for several reasons; Compared to the TInvertedDistanceWeightingSampler, the TVoronoiSampler will be the destination for high power values. At the same time it is related to Delaunay triangulation, which can be used in combination with barycentric interpolation for smooth color gradients.

As the Voronoi sampler typically does not contain any algorithm for antialiasing itself, use of a TSuperSampler might be required for smooth edges

DirectSupersampled

Mathematics & Algorithm ​

Given N seed site points Pi with colors Ci, TVoronoiSampler partitions space into Voronoi cells Vi:

Vi={P∣d(P,Pi)≤d(P,Pj)∀j≠i}

The metric function d(P,Pi) is selected via Metric (TVoronoiMetric):

  • Euclidean: d=(X−Xi)2+(Y−Yi)2
  • Manhattan: d=|X−Xi|+|Y−Yi|
  • Custom: Evaluated via MetricFunc.

Sampling point P returns color Ck of the nearest site Pk.

References ​