TurbulencePrimitive Class

A primitive that fills its subregion with Perlin noise: feTurbulence of SVG.

public sealed class TurbulencePrimitive : FilterPrimitive

Remarks

The noise is the one of the reference code of "Filter Effects Module Level 1", transcribed: the same random numbers from the seed, the same lattice, the same gradients, the same octaves, with a separate noise for the red, the green, the blue and the alpha. A pixel takes the noise at the point of the drawing of its top left corner. The values are straight colors, clamped to the range from 0 to 1, in the colors of the primitive (linear light by default).

With TurbulencePrimitive.StitchTiles, the frequencies are adjusted so that the noise repeats with the size of the subregion (its FilterPrimitive.Subregion, or the region of the filter), and the lattice wraps there. The noise only involves additions, multiplications, divisions and square roots: it is the same on every platform. At most 32 octaves are computed: the others add less than 2^-32.

Inheritance
FilterPrimitive TurbulencePrimitive

Constructors

NameDescription
TurbulencePrimitive(FilterTurbulenceType, double, double, int, int)Initializes a new instance of the TurbulencePrimitive class.

TurbulencePrimitive(FilterTurbulenceType, double, double, int, int)

TurbulencePrimitive.cs

Initializes a new instance of the TurbulencePrimitive class.

public TurbulencePrimitive(FilterTurbulenceType type, double baseFrequencyX, double baseFrequencyY, int octaves, int seed)

Parameters

type FilterTurbulenceType
The noise.
baseFrequencyX double
The frequency of the first octave along x, in cycles per unit of the drawing: baseFrequency.
baseFrequencyY double
The frequency of the first octave along y.
octaves int
The number of octaves: numOctaves. Must be zero or positive.
seed int
The seed of the random numbers: seed, truncated to an integer.

Exceptions

ArgumentOutOfRangeException
type is not defined, a frequency is negative or not a finite number, or octaves is negative.

Properties

NameDescription
BaseFrequencyXGets the frequency of the first octave along x.
BaseFrequencyYGets the frequency of the first octave along y.
OctavesGets the number of octaves.
SeedGets the seed of the random numbers.
StitchTilesGets a value indicating whether the noise repeats with the size of the subregion: stitchTiles="stitch".
TypeGets the noise.

Gets the frequency of the first octave along x.

public double BaseFrequencyX { get; }

Property value

double

Gets the frequency of the first octave along y.

public double BaseFrequencyY { get; }

Property value

double

Gets the number of octaves.

public int Octaves { get; }

Property value

int

Gets the seed of the random numbers.

public int Seed { get; }

Property value

int

Gets a value indicating whether the noise repeats with the size of the subregion: stitchTiles="stitch".

public bool StitchTiles { get; init; }

Property value

bool

Gets the noise.

public FilterTurbulenceType Type { get; }

Property value

FilterTurbulenceType