PdfShading Class

A smooth shading (ISO 32000-2, 8.7.4.5): a gradient painted with PdfContentBuilder.PaintShading or used by a PdfShadingPattern. A shading does not belong to a document: each document that uses it gets its own object. The instances are immutable.

public abstract class PdfShading

Properties

NameDescription
AntiAliasGets or initializes whether the shading is antialiased.
BackgroundGets or initializes the background color, painted outside the shading when it is used by a pattern; null for none.
ColorSpaceGets the color space of the colors of the shading.

AntiAlias

PdfShading.cs

Gets or initializes whether the shading is antialiased.

public bool AntiAlias { get; init; }

Property value

bool

Background

PdfShading.cs

Gets or initializes the background color, painted outside the shading when it is used by a pattern; null for none.

public PdfColor? Background { get; init; }

Property value

PdfColor?

ColorSpace

PdfShading.cs

Gets the color space of the colors of the shading.

public PdfDeviceColorSpace ColorSpace { get; }

Property value

PdfDeviceColorSpace

Methods

NameDescription
Axial(PdfDeviceColorSpace, double, double, double, double, PdfFunction, bool, bool)Creates an axial shading (type 2, 8.7.4.5.3): the colors vary along the line from the start point to the end point.
CoonsPatchMesh(PdfDeviceColorSpace, IReadOnlyList<PdfPatch>)Creates a Coons patch mesh (type 6, 8.7.4.5.7): patches bounded by four cubic Bézier curves, with a color at each corner.
FunctionBased(PdfDeviceColorSpace, PdfFunction, double[]?, PdfMatrix?)Creates a function-based shading (type 1, 8.7.4.5.2): the color of each point of the domain is the output of a function of two inputs.
LatticeMesh(PdfDeviceColorSpace, int, IReadOnlyList<PdfMeshVertex>)Creates a lattice-form Gouraud-shaded triangle mesh (type 5, 8.7.4.5.6): rows of vertices, each two consecutive rows forming the triangles of a strip.
Radial(PdfDeviceColorSpace, double, double, double, double, double, double, PdfFunction, bool, bool)Creates a radial shading (type 3, 8.7.4.5.4): the colors vary between two circles.
TensorPatchMesh(PdfDeviceColorSpace, IReadOnlyList<PdfPatch>)Creates a tensor-product patch mesh (type 7, 8.7.4.5.8): the patches of PdfShading.CoonsPatchMesh with four more control points inside each one (PdfPatch.InnerPoints).
TriangleMesh(PdfDeviceColorSpace, IReadOnlyList<(PdfMeshVertex A, PdfMeshVertex B, PdfMeshVertex C)>)Creates a free-form Gouraud-shaded triangle mesh (type 4, 8.7.4.5.5).

Axial(PdfDeviceColorSpace, double, double, double, double, PdfFunction, bool, bool)

PdfShading.cs

Creates an axial shading (type 2, 8.7.4.5.3): the colors vary along the line from the start point to the end point.

public static PdfShading Axial(PdfDeviceColorSpace colorSpace, double x0, double y0, double x1, double y1, PdfFunction function, bool extendStart = false, bool extendEnd = false)

Parameters

colorSpace PdfDeviceColorSpace
The color space.
x0 double
The x coordinate of the start point.
y0 double
The y coordinate of the start point.
x1 double
The x coordinate of the end point.
y1 double
The y coordinate of the end point.
function PdfFunction
The function from the position on the line (0 to 1) to the components of the color.
extendStart bool
Whether the shading extends beyond the start point.
extendEnd bool
Whether the shading extends beyond the end point.

Returns

PdfShading The shading.

CoonsPatchMesh(PdfDeviceColorSpace, IReadOnlyList<PdfPatch>)

PdfShading.cs

Creates a Coons patch mesh (type 6, 8.7.4.5.7): patches bounded by four cubic Bézier curves, with a color at each corner.

public static PdfShading CoonsPatchMesh(PdfDeviceColorSpace colorSpace, IReadOnlyList<PdfPatch> patches)

Parameters

colorSpace PdfDeviceColorSpace
The color space.
patches IReadOnlyList<PdfPatch>
The patches.

Returns

PdfShading The shading.

FunctionBased(PdfDeviceColorSpace, PdfFunction, double[]?, PdfMatrix?)

PdfShading.cs

Creates a function-based shading (type 1, 8.7.4.5.2): the color of each point of the domain is the output of a function of two inputs.

public static PdfShading FunctionBased(PdfDeviceColorSpace colorSpace, PdfFunction function, double[]? domain = null, PdfMatrix? matrix = null)

Parameters

colorSpace PdfDeviceColorSpace
The color space.
function PdfFunction
The function: two inputs, one output per component of the color space.
domain double[]?
The rectangle of the inputs [xmin xmax ymin ymax]; null for [0 1 0 1].
matrix PdfMatrix?
The matrix that maps the domain to the shading space; null for the identity.

Returns

PdfShading The shading.

LatticeMesh(PdfDeviceColorSpace, int, IReadOnlyList<PdfMeshVertex>)

PdfShading.cs

Creates a lattice-form Gouraud-shaded triangle mesh (type 5, 8.7.4.5.6): rows of vertices, each two consecutive rows forming the triangles of a strip.

public static PdfShading LatticeMesh(PdfDeviceColorSpace colorSpace, int verticesPerRow, IReadOnlyList<PdfMeshVertex> vertices)

Parameters

colorSpace PdfDeviceColorSpace
The color space.
verticesPerRow int
The number of vertices of each row, at least 2.
vertices IReadOnlyList<PdfMeshVertex>
The vertices, row by row; at least two rows.

Returns

PdfShading The shading.

Radial(PdfDeviceColorSpace, double, double, double, double, double, double, PdfFunction, bool, bool)

PdfShading.cs

Creates a radial shading (type 3, 8.7.4.5.4): the colors vary between two circles.

public static PdfShading Radial(PdfDeviceColorSpace colorSpace, double x0, double y0, double r0, double x1, double y1, double r1, PdfFunction function, bool extendStart = false, bool extendEnd = false)

Parameters

colorSpace PdfDeviceColorSpace
The color space.
x0 double
The x coordinate of the center of the start circle.
y0 double
The y coordinate of the center of the start circle.
r0 double
The radius of the start circle.
x1 double
The x coordinate of the center of the end circle.
y1 double
The y coordinate of the center of the end circle.
r1 double
The radius of the end circle.
function PdfFunction
The function from the position between the circles (0 to 1) to the components of the color.
extendStart bool
Whether the shading extends beyond the start circle.
extendEnd bool
Whether the shading extends beyond the end circle.

Returns

PdfShading The shading.

TensorPatchMesh(PdfDeviceColorSpace, IReadOnlyList<PdfPatch>)

PdfShading.cs

Creates a tensor-product patch mesh (type 7, 8.7.4.5.8): the patches of PdfShading.CoonsPatchMesh with four more control points inside each one (PdfPatch.InnerPoints).

public static PdfShading TensorPatchMesh(PdfDeviceColorSpace colorSpace, IReadOnlyList<PdfPatch> patches)

Parameters

colorSpace PdfDeviceColorSpace
The color space.
patches IReadOnlyList<PdfPatch>
The patches.

Returns

PdfShading The shading.

TriangleMesh(PdfDeviceColorSpace, IReadOnlyList<(PdfMeshVertex A, PdfMeshVertex B, PdfMeshVertex C)>)

PdfShading.cs

Creates a free-form Gouraud-shaded triangle mesh (type 4, 8.7.4.5.5).

public static PdfShading TriangleMesh(PdfDeviceColorSpace colorSpace, IReadOnlyList<(PdfMeshVertex A, PdfMeshVertex B, PdfMeshVertex C)> triangles)

Parameters

colorSpace PdfDeviceColorSpace
The color space.
triangles IReadOnlyList<(PdfMeshVertex A, PdfMeshVertex B, PdfMeshVertex C)>
The triangles: three vertices each, whose colors are interpolated inside the triangle.

Returns

PdfShading The shading.