Class Shading
Shading is a class that represents a flat interface around all PDF shading types:
- In Function-based (type 1) shadings, the color at every point in the domain is defined by a specified mathematical function. The function need not be smooth or continuous. This is the most general of the available shading types, and is useful for shadings that cannot be adequately described with any of the other types.
- 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.
- Radial shadings (type 3) define a color blend that varies between two circles. Shadings of this type are commonly used to depict three-dimensional spheres and cones.
- Free-form Gouraud-shaded triangle mesh shadings (type 4) and lattice gouraud shadings (type 5) are commonly used to represent complex colored and shaded three-dimensional shapes. The area to be shaded is defined by a path composed entirely of triangles. The color at each vertex of the triangles is specified, and a technique known as Gouraud interpolation is used to color the interiors. The interpolation functions defining the shading may be linear or nonlinear.
A Coons patch generally has two independent aspects:
- Colors are specified for each corner of the unit square, and bilinear interpolation is used to fill in colors over the entire unit square
- Coordinates are mapped from the unit square into a four-sided patch whose sides are not necessarily linear. The mapping is continuous: the corners of the unit square map to corners of the patch and the sides of the unit square map to sides of the patch.
- Tensor-product patch mesh shadings (type 7) are identical to type 6 (Coons mesh), except that they are based on a bicubic tensor-product patch defined by 16 control points, instead of the 12 control points that define a Coons patch. The shading Patterns dictionaries representing the two patch types differ only in the value of the Type entry and in the number of control points specified for each patch in the data stream. Although the Coons patch is more concise and easier to use, the tensor- product patch affords greater control over color mapping.
Implements
Inherited Members
Namespace: pdftron.PDF
Assembly: PDFNet.dll
Syntax
public class Shading : IDisposable
Constructors
Shading(Obj)
Create a Shading from the given SDF/Cos object listed under /Shading entry in the page Resource dictionary.
Declaration
public Shading(Obj shading_dict)
Parameters
Type | Name | Description |
---|---|---|
Obj | shading_dict | shading dictionary |
Methods
Create(Obj)
Create a Shading from the given SDF/Cos object listed under /Shading entry in the page Resource dictionary.
Declaration
public static Shading Create(Obj shading_dict)
Parameters
Type | Name | Description |
---|---|---|
Obj | shading_dict | shading dictionary |
Returns
Type | Description |
---|---|
Shading | newly created |
Dispose()
Releases all resources used by the Shading
Declaration
public override sealed void Dispose()
Dispose(bool)
Declaration
[HandleProcessCorruptedStateExceptions]
protected virtual void Dispose(bool A_0)
Parameters
Type | Name | Description |
---|---|---|
bool | A_0 |
~Shading()
Allows a Shading to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
Declaration
protected ~Shading()
GetAntialias()
Gets the antialias.
Declaration
public bool GetAntialias()
Returns
Type | Description |
---|---|
bool | A flag indicating whether to filter the shading function to prevent aliasing artifacts. See Table 4.25 |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetBBox()
Gets the bounding box.
Declaration
public Rect GetBBox()
Returns
Type | Description |
---|---|
Rect | a rectangle giving the left, bottom, right, and top coordinates, respectively, of the shading's bounding box. The coordinates are interpreted in the shading's target coordinate space. If present, this bounding box is 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. |
Remarks
Use HasBBox() method to determine whether the shading has a background color.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetBackground()
An color point represented in base color space specifying a single background color value. If present, this color is 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 itself. In the opaque imaging model, the effect is as if the painting operation were performed twice: first with the background color and then again with the shading.
Declaration
public ColorPt GetBackground()
Returns
Type | Description |
---|---|
ColorPt | the background color point |
Remarks
The background color is applied only when the shading is used as part
of a shading pattern, not when it is painted directly with the sh operator.
Use HasBackground()
method to determine whether the shading has a
background color.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetBaseColorSpace()
Gets the base color space.
Declaration
public ColorSpace GetBaseColorSpace()
Returns
Type | Description |
---|---|
ColorSpace | The color space in which color values are expressed. This may be any device, CIE-based, or special color space except a Pattern space. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetColor(double, double, ColorPt)
Gets the color.
Declaration
public virtual void GetColor(double t1, double t2, ColorPt out_color)
Parameters
Type | Name | Description |
---|---|---|
double | t1 | t1 |
double | t2 | t2 |
ColorPt | out_color | a color point for the given value of parametric variable (t1, t2). |
Exceptions
Type | Condition |
---|---|
PDFNetException | for shadings other than Function this method throws an exception. |
GetColor(double, ColorPt)
Gets the color.
Declaration
public virtual void GetColor(double t, ColorPt out_color)
Parameters
Type | Name | Description |
---|---|---|
double | t | color point |
ColorPt | out_color | a color point for the given value of t. |
Exceptions
Type | Condition |
---|---|
PDFNetException | for shadings other than Axial or Radial this method throws an exception. |
GetCoords(ref double, ref double, ref double, ref double)
Gets the coords radial.
Declaration
public virtual void GetCoords(ref double out_x0, ref double out_y0, ref double out_x1, ref double out_y1)
Parameters
Type | Name | Description |
---|---|---|
double | out_x0 | x0 |
double | out_y0 | y0 |
double | out_x1 | x1 |
double | out_y1 | y1 |
Remarks
for Radial shading returns six numbers (x0 y0 r0 x1 y1 r1) specifying the centers and radii of the starting and ending circles, expressed in the shading's target coordinate space. The radii r0 and r1 must both be greater than or equal to 0. If one radius is 0, the corresponding circle is treated as a point; if both are 0, nothing is painted.
Exceptions
Type | Condition |
---|---|
PDFNetException | for shadings other than Radial this method throws an exception. |
GetCoords(ref double, ref double, ref double, ref double, ref double, ref double)
Gets the coords radial.
Declaration
public virtual void GetCoords(ref double out_x0, ref double out_y0, ref double out_r0, ref double out_x1, ref double out_y1, ref double out_r1)
Parameters
Type | Name | Description |
---|---|---|
double | out_x0 | x0 |
double | out_y0 | y0 |
double | out_r0 | r0 |
double | out_x1 | x1 |
double | out_y1 | y1 |
double | out_r1 | r1 |
Remarks
for Radial shading returns six numbers (x0 y0 r0 x1 y1 r1) specifying the centers and radii of the starting and ending circles, expressed in the shading's target coordinate space. The radii r0 and r1 must both be greater than or equal to 0. If one radius is 0, the corresponding circle is treated as a point; if both are 0, nothing is painted.
Exceptions
Type | Condition |
---|---|
PDFNetException | for shadings other than Radial this method throws an exception. |
GetDomain(ref double, ref double, ref double, ref double)
Gets the domain.
Declaration
public virtual void GetDomain(ref double out_minx, ref double out_maxx, ref double out_miny, ref double out_maxy)
Parameters
Type | Name | Description |
---|---|---|
double | out_minx | minimum x |
double | out_maxx | maximum x |
double | out_miny | minimum y |
double | out_maxy | maximum y |
Remarks
for shadings other than Function this method throws an exception.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetMatrix()
Gets the matrix.
Declaration
public virtual Matrix2D GetMatrix()
Returns
Type | Description |
---|---|
Matrix2D | a matrix specifying a mapping from the coordinate space specified by the Domain entry into the shading's target coordinate space. |
Remarks
for shadings other than Function this method throws an exception.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetParamEnd()
Gets the param end.
Declaration
public virtual double GetParamEnd()
Returns
Type | Description |
---|---|
double | a number specifying the limiting value of a parametric variable t. The variable is considered to vary linearly between GetParamStart() and GetParamEnd() as the color gradient varies between the starting and ending points of the axis for Axial shading or circles for Radial shading. The variable t becomes the input argument to the color function(s). |
Remarks
the returned value corresponds to the second value in Domain array. for shadings other than Axial or Radial this method throws an exception.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetParamStart()
Gets the param start.
Declaration
public virtual double GetParamStart()
Returns
Type | Description |
---|---|
double | a number specifying the limiting value of a parametric variable t. The variable is considered to vary linearly between GetParamStart() and GetParamEnd() as the color gradient varies between the starting and ending points of the axis for Axial shading or circles for Radial shading. The variable t becomes the input argument to the color function(s). |
Remarks
the returned value corresponds to the first value in Domain array. for shadings other than Axial or Radial this method throws an exception.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetSDFObj()
Gets the SDFObj.
Declaration
public Obj GetSDFObj()
Returns
Type | Description |
---|---|
Obj | the underlying SDF/Cos object |
GetType()
Gets the shading type.
Declaration
public virtual Shading.Type GetType()
Returns
Type | Description |
---|---|
Shading.Type | The Type of a given SDF/Cos shading dictionary, or e_null for if SDF object is not a valid shading object |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetType(Obj)
Gets shading type from shading dictionary.
Declaration
public static Shading.Type GetType(Obj shading_dict)
Parameters
Type | Name | Description |
---|---|---|
Obj | shading_dict | the shading dictionary |
Returns
Type | Description |
---|---|
Shading.Type | The Type of a given SDF/Cos shading dictionary, or e_null for if SDF object is not a valid shading object |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
HasBBox()
Checks for bounding box.
Declaration
public bool HasBBox()
Returns
Type | Description |
---|---|
bool | true if shading has a bounding box, false otherwise. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
HasBackground()
Checks for background.
Declaration
public bool HasBackground()
Returns
Type | Description |
---|---|
bool | true if the shading has a background color or false otherwise. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
IsExtendEnd()
Checks if is extend end.
Declaration
public virtual bool IsExtendEnd()
Returns
Type | Description |
---|---|
bool | a flag specifying whether to extend the shading beyond the ending point of the axis for Axial shading or ending circle for Radial shading. |
Remarks
for shadings other than Axial or Radial this method throws an exception.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
IsExtendStart()
Checks if is extend start.
Declaration
public virtual bool IsExtendStart()
Returns
Type | Description |
---|---|
bool | a flag specifying whether to extend the shading beyond the starting point of the axis for Axial shading or starting circle for Radial shading. |
Remarks
for shadings other than Axial or Radial this method throws an exception.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |