PdfShading Class
A shading dictionary specifies details of a particular gradient fill, including the type of shading to be used, the geometry of the area to be shaded, and the geometry of the gradient fill.
public abstract class PdfShading : PdfContentResource
Public MustInherit Class PdfShading
Inherits PdfContentResource
- Inheritance:
- System.ObjectPdfShading
- Derived
Remarks
Various shading types are available, depending on the value of the ShadingType entry:
- PdfFunctionBasedShading: Function-based shadings (type 1) define the color of every point in the domain using a mathematical function (not necessarily smooth or continuous).
- PdfAxialShading: Axial shadings (type 2) define a color blend along a line between two points, optionally extended beyond the boundary points by continuing the boundary colors.
- PdfRadialShading: Radial shadings (type 3) define a blend between two circles, optionally extended beyond the boundary circles by continuing the boundary colors. This type of shading is commonly used to represent three-dimensional spheres and cones.
- PdfFreeTriangleMeshShading: Free-form Gouraud-shaded triangle meshes (type 4) define a common construct used by many three-dimensional applications to represent complex colored and shaded shapes. Vertices are specified in free-form geometry.
- PdfLatticeTriangleMeshShading: Lattice-form Gouraud-shaded triangle meshes (type 5) are based on the same geometrical construct as type 4 but with vertices specified as a pseudorectangular lattice.
- PdfCoonsPatchMeshShading: Coons patch meshes (type 6) construct a shading from one or more color patches, each bounded by four cubic Bézier curves.
- PdfTensorPatchMeshShading: Tensor-product patch meshes (type 7) are similar to type 6 but with additional control points in each patch, affording greater control over color mapping.
Properties
Background
(Optional) A color appropriate to the ColorSpace, specifying a single background color. If present, this color shall be used, before any painting operation involving the shading, to fill those portions of the area to be painted that lie outside the bounds of the shading object.
note
In the opaque imaging model, the effect is as if the painting operation were performed twice: first with the background color and then with the shading.
note
The background color is applied only when the shading is used as part of a PdfShadingPattern, not when it is painted directly with the PdfShadingContent operator.
Property Value
- System.Nullable<PdfColor>
A color appropriate to the color space, specifying a single background color.
Exceptions
- System.ArgumentException
Shading background Space is not the same as the shading ColorSpace.
See Also
BoundingBox
(Optional) A rectangle giving the left, bottom, right, and top coordinates, respectively, of the shading's bounding box. The coordinates shall be interpreted in the shading's target coordinate space. If present, this bounding box shall be applied as a temporary clipping boundary when the shading is painted, in addition to the current clipping path and any other clipping boundaries in effect at that time.
Property Value
An rectangle giving the left, bottom, right, and top coordinates, respectively, of the shading's bounding box.
See Also
ColorSpace
(Required) The color space in which color values shall be expressed. This may be any device, CIE-based, or special color space except a Pattern space. See 8.7.4.4, "Color Space: Special Considerations" for further information.
public PdfColorSpace ColorSpace { get; }
Public ReadOnly Property ColorSpace As PdfColorSpace
Property Value
The color space in which color values shall be expressed.
See Also
IsAntiAlias
(Optional) A flag indicating whether to filter the shading function to prevent aliasing artifacts.
note
The shading operators sample shading functions at a rate determined by the resolution of the output device. Aliasing can occur if the function is not smooth—that is, if it has a high spatial frequency relative to the sampling rate. Anti-aliasing can be computationally expensive and is usually unnecessary, since most shading functions are smooth enough or are sampled at a high enough frequency to avoid aliasing effects. Anti-aliasing may not be implemented on some output devices, in which case this flag is ignored.
Default value: false.
Property Value
- System.Boolean
See Also
ShadingType
(Required) The shading type.
public virtual PdfShadingType ShadingType { get; }
Public Overridable ReadOnly Property ShadingType As PdfShadingType
Property Value
The shading type.
See Also
Methods
CreateFunction(IList<PdfShadingColor>)
Creates an interpolation function from the specified list of PdfShadingColors.
Two colors
create a PdfExponentialInterpolationFunction and more than two create a PdfStitchingFunction (stitching two or more PdfExponentialInterpolationFunctions).
The function's Domain is set from the Offset of the first and the last PdfShadingColor.
public static IList<PdfFunction> CreateFunction(IList<PdfShadingColor> colors)
Public Shared Function CreateFunction(colors As IList(Of PdfShadingColor)) As IList(Of PdfFunction)
Parameters
colors
- System.Collections.Generic.IList<PdfShadingColor>
The PdfShadingColors for which to create an interpolation function.
Returns
- System.Collections.Generic.IList<PdfFunction>
Exceptions
- System.ArgumentNullException
colors
is null.
- System.ArgumentException
colors
count is less than 2 or Color spaces of PdfShadingColors are not equal or Offset of any PdfShadingColor is not greater than the Offset of all previous PdfShadingColors.
SetBoundingBox(Double, Double, Double, Double)
Sets the BoundingBox.
public void SetBoundingBox(double left, double bottom, double right, double top)
Public Sub SetBoundingBox(left As Double, bottom As Double, right As Double, top As Double)
Parameters
left
- System.Double
The left X coordinate of the BoundingBox.
bottom
- System.Double
The bottom Y coordinate of the BoundingBox.
right
- System.Double
The right X coordinate of the BoundingBox.
top
- System.Double
The top Y coordinate of the BoundingBox.
Inherited Properties
Document | Gets the PdfDocument associated with this PdfContentResource or null if no PdfDocument is associated with this PdfContentResource. (Inherited from PdfContentResource) |
Metadata | (Optional; PDF 1.4) A metadata stream containing metadata for the component. (Inherited from PdfObject) |