FilterGraph Class

A filter made of primitives that read the drawing, its alpha, and each other's results: an SVG filter element.

public sealed class FilterGraph : Filter

Remarks

The primitives are computed in order. Each one reads its inputs (FilterInput: by default the result of the primitive before it, or the drawing for the first one) and computes its result in its subregion (FilterPrimitive.Subregion), transparent outside it. The result of the last primitive is the result of the filter, and nothing is drawn outside FilterGraph.Region.

Each primitive computes with the colors of its FilterPrimitive.ColorSpace (color-interpolation-filters): by default, as in SVG, in linear light, the inputs decoded by the transfer function of sRGB and the result encoded again, evaluated without any function of the platform (within a few units in the last place of double precision of the exact function, so the same values on every platform). A primitive that only moves or copies pixels (OffsetPrimitive, TilePrimitive) or makes a color (FloodPrimitive) gives the same pixels in both, and converts nothing.

The rectangles of the graph are in the coordinates of the drawing: a subregion is the set of pixels whose center is in the box of the image of its rectangle on the canvas. The inputs BackgroundImage, BackgroundAlpha, FillPaint and StrokePaint of SVG are not supported.

Inheritance
Filter FilterGraph

Constructors

NameDescription
FilterGraph(ReadOnlySpan<FilterPrimitive>)Initializes a new instance of the FilterGraph class.

FilterGraph(ReadOnlySpan<FilterPrimitive>)

FilterGraph.cs

Initializes a new instance of the FilterGraph class.

public FilterGraph(params scoped ReadOnlySpan<FilterPrimitive> primitives)

Parameters

primitives ReadOnlySpan<FilterPrimitive>
The primitives, in the order they are computed. They are copied.

Exceptions

ArgumentNullException
A primitive is null.
ArgumentException
There is no primitive, or a primitive reads the result of a primitive that is not before it.

Properties

NameDescription
PrimitivesGets the primitives, in the order they are computed.
RegionGets the rectangle of the drawing the filter draws in (the filter region of SVG), or null (the default) for the whole canvas. The rectangle can go beyond the canvas: what is drawn there, within the reach of the filter, is read by the primitives.

Primitives

FilterGraph.cs

Gets the primitives, in the order they are computed.

public IReadOnlyList<FilterPrimitive> Primitives { get; }

Gets the rectangle of the drawing the filter draws in (the filter region of SVG), or null (the default) for the whole canvas. The rectangle can go beyond the canvas: what is drawn there, within the reach of the filter, is read by the primitives.

public RectangleD? Region { get; init; }

Property value

RectangleD?

Exceptions

ArgumentException
A coordinate is not a finite number.
ArgumentOutOfRangeException
The magnitude of a coordinate exceeds 16777216.