# PdfCoonsPatchMeshShading Class

Type 6 shadings (Coons patch meshes) are constructed from one or more *color patches*, each bounded by four cubic Bézier curves.

`public sealed class PdfCoonsPatchMeshShading : PdfMeshShading, IEnumerable<PdfMeshPatch>, IEnumerable`

```
Public NotInheritable Class PdfCoonsPatchMeshShading
Inherits PdfMeshShading
Implements IEnumerable(Of PdfMeshPatch), IEnumerable
```

- Inheritance:
- PdfCoonsPatchMeshShading

### Constructors

#### PdfCoonsPatchMeshShading(IList<PdfFunction>, PdfColorSpace)

Initializes a new instance of the PdfCoonsPatchMeshShading class with an optional ColorSpace.

The Add(PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint) overload must be used to populate a mesh with a new patch, unconnected to any other. Subsequent, connected, patches can be added with the Add(PdfMeshSharedEdge, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint) overload.

If the `function`

parameter is omitted or is null, then the PdfMeshVertex(Double, Double, PdfColor) constructor should be used for creating vertices; otherwise, the PdfMeshVertex(Double, Double, Double) constructor should be used. You can use the static method CreateFunction(IList<PdfShadingColor>) to create an interpolation function from two or more PdfShadingColors.

##### note

The Pack(Boolean) method must be used after the mesh is populated to resolve the values of the BitsPerCoordinate, BitsPerComponent, BitsPerFlag, and Decode entries and to serialize the mesh data to the underlying stream.

`public PdfCoonsPatchMeshShading(IList<PdfFunction> function = null, PdfColorSpace colorSpace = null)`

`Public Sub New(function As IList(Of PdfFunction) = Nothing, colorSpace As PdfColorSpace = Nothing)`

##### Parameters

`function`

- IList<PdfFunction>

The optional value of the Function entry.

`colorSpace`

- PdfColorSpace

The color space in which color values shall be expressed. If omitted, the DeviceRGB is used.

#### PdfCoonsPatchMeshShading(Int32, Int32, Int32, PdfNumberRange, PdfNumberRange, IList<PdfFunction>, PdfColorSpace)

Initializes a new instance of the PdfCoonsPatchMeshShading class that has the specified mesh data serialization settings and, optionally, ColorSpace.

The Add(PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint) overload must be used to populate a mesh with a new patch, unconnected to any other. Subsequent, connected, patches can be added with the Add(PdfMeshSharedEdge, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint) overload.

If the `function`

parameter is omitted or is null, then the PdfMeshVertex(Double, Double, PdfColor) constructor should be used for creating vertices; otherwise, the PdfMeshVertex(Double, Double, Double) constructor should be used. You can use the static method CreateFunction(IList<PdfShadingColor>) to create an interpolation function from two or more PdfShadingColors.

The Decode entry is set based on the `decodeX`

, `decodeY`

, and ranges of valid color component values specified by the Function's domain or ColorSpace. The Decode for color components can be subsequently updated (it starts with a PdfNumberRange at index 2 in the Decode entry).

`public PdfCoonsPatchMeshShading(int bitsPerCoordinate, int bitsPerComponent, int bitsPerFlag, PdfNumberRange decodeX, PdfNumberRange decodeY, IList<PdfFunction> function = null, PdfColorSpace colorSpace = null)`

`Public Sub New(bitsPerCoordinate As Integer, bitsPerComponent As Integer, bitsPerFlag As Integer, decodeX As PdfNumberRange, decodeY As PdfNumberRange, function As IList(Of PdfFunction) = Nothing, colorSpace As PdfColorSpace = Nothing)`

##### Parameters

`bitsPerCoordinate`

- Int32

The number of bits used to represent each geometric coordinate. The value shall be 1, 2, 4, 8, 12, 16, 24, or 32.

`bitsPerComponent`

- Int32

The number of bits used to represent each color component. The value shall be 1, 2, 4, 8, 12, or 16.

`bitsPerFlag`

- Int32

The number of bits used to represent the edge flag for each patch. The value of `bitsPerFlag`

shall be 2, 4, or 8, but only the least significant 2 bits in each flag value shall be used.

`decodeX`

- PdfNumberRange

A PdfNumberRange specifying how to map horizontal component of patch coordinates into the appropriate range of values.

`decodeY`

- PdfNumberRange

A PdfNumberRange specifying how to map vertical component of patch coordinates into the appropriate range of values.

`function`

- IList<PdfFunction>

The optional value of the Function entry.

`colorSpace`

- PdfColorSpace

The color space in which color values shall be expressed. If omitted, the DeviceRGB is used.

##### Exceptions

`bitsPerCoordinate`

is not 1, 2, 4, 8, 12, 16, 24, or 32.

`bitsPerComponent`

is not 1, 2, 4, 8, 12, or 16.

`bitsPerFlag`

is not 2, 4, or 8.

### Properties

#### BitsPerFlag

*(Required)* The number of bits used to represent the edge flag for each patch. The value of BitsPerFlag shall be 2, 4, or 8, but only the least significant 2 bits in each flag value shall be used. The value for the edge flag shall be 0, 1, 2, or 3.

##### Property Value

The number of bits used to represent the edge flag for each patch.

##### Exceptions

Argument must be one of the following values: 2, 4, or 8.

##### See Also

#### ShadingType

Gets the CoonsPatchMesh value.

`public override PdfShadingType ShadingType { get; }`

`Public Overrides ReadOnly Property ShadingType As PdfShadingType`

##### Property Value

The CoonsPatchMesh value.

##### Overrides

### Methods

#### Add(PdfMeshSharedEdge, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint)

Populates a mesh with a subsequent, connected, patch.

If the `edgeFlag`

is Edge1, then the edge between the second (Vertex03) and the third (Vertex33) (corner) vertex of the previous patch is shared with a subsequent, connected, patch as an edge between its first (Vertex00) and second (Vertex03) (corner) vertex.

If the `edgeFlag`

is Edge2, then the edge between the third (Vertex33) and the fourth (Vertex30) (corner) vertex of the previous patch is shared with a subsequent, connected, patch as an edge between its first (Vertex00) and second (Vertex03) (corner) vertex.

If the `edgeFlag`

is Edge3, then the edge between the fourth (Vertex30) and the first (Vertex00) (corner) vertex of the previous patch is shared with a subsequent, connected, patch as an edge between its first (Vertex00) and second (Vertex03) (corner) vertex.

`public void Add(PdfMeshSharedEdge edgeFlag, PdfPoint point13, PdfPoint point23, PdfMeshVertex vertex33, PdfPoint point32, PdfPoint point31, PdfMeshVertex vertex30, PdfPoint point20, PdfPoint point10)`

`Public Sub Add(edgeFlag As PdfMeshSharedEdge, point13 As PdfPoint, point23 As PdfPoint, vertex33 As PdfMeshVertex, point32 As PdfPoint, point31 As PdfPoint, vertex30 As PdfMeshVertex, point20 As PdfPoint, point10 As PdfPoint)`

##### Parameters

`edgeFlag`

- PdfMeshSharedEdge

The flag specifying the edge of the previous patch that is shared with a subsequent, connected, patch.

`point13`

- PdfPoint

The coordinates of the first control point of a cubic Bézier curve that connects Vertex03 and `vertex33`

.

`point23`

- PdfPoint

The coordinates of the second control point of a cubic Bézier curve that connects Vertex03 and `vertex33`

.

`vertex33`

- PdfMeshVertex

The third (corner) vertex of a new patch.

`point32`

- PdfPoint

The coordinates of the second control point of a cubic Bézier curve that connects `vertex30`

and `vertex33`

.

`point31`

- PdfPoint

The coordinates of the first control point of a cubic Bézier curve that connects `vertex30`

and `vertex33`

.

`vertex30`

- PdfMeshVertex

The fourth (corner) vertex of a new patch.

`point20`

- PdfPoint

The coordinates of the second control point of a cubic Bézier curve that connects Vertex00 and `vertex30`

.

`point10`

- PdfPoint

The coordinates of the first control point of a cubic Bézier curve that connects Vertex00 and `vertex30`

.

##### Exceptions

The Function entry is set and the IsColorParametric property of `vertex33`

or `vertex30`

is false or the Function entry is not set and the IsColorParametric property of `vertex33`

or `vertex30`

is true.

The Space of the Color of `vertex33`

or `vertex30`

is not equal to the shading's ColorSpace.

This overload cannot be used on an empty mesh. Use the Add(PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint) before.

#### Add(PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint, PdfMeshVertex, PdfPoint, PdfPoint)

Populates a mesh with a new patch, unconnected to any other.

`public void Add(PdfMeshVertex vertex00, PdfPoint point01, PdfPoint point02, PdfMeshVertex vertex03, PdfPoint point13, PdfPoint point23, PdfMeshVertex vertex33, PdfPoint point32, PdfPoint point31, PdfMeshVertex vertex30, PdfPoint point20, PdfPoint point10)`

`Public Sub Add(vertex00 As PdfMeshVertex, point01 As PdfPoint, point02 As PdfPoint, vertex03 As PdfMeshVertex, point13 As PdfPoint, point23 As PdfPoint, vertex33 As PdfMeshVertex, point32 As PdfPoint, point31 As PdfPoint, vertex30 As PdfMeshVertex, point20 As PdfPoint, point10 As PdfPoint)`

##### Parameters

`vertex00`

- PdfMeshVertex

The first (corner) vertex of a new patch.

`point01`

- PdfPoint

The coordinates of the first control point of a cubic Bézier curve that connects `vertex00`

and `vertex03`

.

`point02`

- PdfPoint

The coordinates of the second control point of a cubic Bézier curve that connects `vertex00`

and `vertex03`

.

`vertex03`

- PdfMeshVertex

The second (corner) vertex of a new patch.

`point13`

- PdfPoint

The coordinates of the first control point of a cubic Bézier curve that connects `vertex03`

and `vertex33`

.

`point23`

- PdfPoint

The coordinates of the second control point of a cubic Bézier curve that connects `vertex03`

and `vertex33`

.

`vertex33`

- PdfMeshVertex

The third (corner) vertex of a new patch.

`point32`

- PdfPoint

The coordinates of the second control point of a cubic Bézier curve that connects `vertex30`

and `vertex33`

.

`point31`

- PdfPoint

The coordinates of the first control point of a cubic Bézier curve that connects `vertex30`

and `vertex33`

.

`vertex30`

- PdfMeshVertex

The fourth (corner) vertex of a new patch.

`point20`

- PdfPoint

The coordinates of the second control point of a cubic Bézier curve that connects `vertex00`

and `vertex30`

.

`point10`

- PdfPoint

The coordinates of the first control point of a cubic Bézier curve that connects `vertex00`

and `vertex30`

.

##### Exceptions

The Function entry is set and the IsColorParametric property of `vertex00`

, `vertex03`

, `vertex33`

, or `vertex30`

is false or the Function entry is not set and the IsColorParametric property of `vertex00`

, `vertex03`

, `vertex33`

, or `vertex30`

is true.

The Space of the Color of `vertex00`

, `vertex03`

, `vertex33`

, or `vertex30`

is not equal to the shading's ColorSpace.

#### GetEnumerator()

Returns an enumerator that iterates PdfMeshPatches contained in this PdfCoonsPatchMeshShading.

`public PdfCoonsPatchMeshShading.Enumerator GetEnumerator()`

`Public Function GetEnumerator As PdfCoonsPatchMeshShading.Enumerator`

##### Returns

##### Exceptions

#### Pack(Boolean)

Packs the mesh data to the underlying PdfStream and, optionally, sets or adjusts the mesh data serialization settings (BitsPerCoordinate, BitsPerComponent, BitsPerFlag, and Decode entries) to the most appropriate values to achieve the best sampled mesh data compaction and resolution, based on the mesh data.

`public PdfCoonsPatchMeshShading Pack(bool resolveSerializationSettings = true)`

`Public Function Pack(resolveSerializationSettings As Boolean = True) As PdfCoonsPatchMeshShading`

##### Parameters

`resolveSerializationSettings`

- Boolean

true to set or adjust the mesh data serialization settings (BitsPerCoordinate, BitsPerComponent, BitsPerFlag, and Decode entries) to the most appropriate values to achieve the best sampled mesh data compaction and resolution, based on the mesh data; otherwise, false.

##### Returns

A reference to this PdfCoonsPatchMeshShading instance after the packing operation has completed.

##### Exceptions

Some of the PdfNumberRanges in the Decode entry are too narrow to encode the mesh data. Extend the bounds of those PdfNumberRanges or use the Pack(Boolean) method with a parameter `resolveSerializationSettings`

set to true.

### Inherited Properties

Background |
## noteIn 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. ## noteThe 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. (Inherited from PdfShading) |

BitsPerComponent |
(Inherited from PdfMeshShading) |

BitsPerCoordinate |
(Inherited from PdfMeshShading) |

BoundingBox |
(Inherited from PdfShading) |

ColorSpace |
(Inherited from PdfShading) |

Decode | (Required) A collection of PdfNumberRanges specifying how to map vertex or geometric coordinates and color components into the appropriate ranges of values. The decoding method is similar to that used in image dictionaries (see 8.9.5.2, "Decode Arrays"). The ranges shall be specified as follows: [( Only one pair of c values shall be specified if a Function entry is present. (Inherited from PdfMeshShading) |

Document | Gets the PdfDocument associated with this PdfContentResource or null if no PdfDocument is associated with this PdfContentResource. (Inherited from PdfContentResource) |

Function |
This entry shall not be used with an Indexed color space. ## tipUse the static method CreateFunction(IList<PdfShadingColor>) to create an interpolation function from two or more PdfShadingColors. (Inherited from PdfMeshShading) |

IsAntiAlias |
## noteThe 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. (Inherited from PdfShading) |

Metadata |
(Inherited from PdfObject) |

### Inherited Methods

CreateFunction(IList<PdfShadingColor>) | Creates an interpolation function from the specified list of PdfShadingColors. Two The function's Domain is set from the Offset of the first and the last PdfShadingColor. (Inherited from PdfShading) |

SetBoundingBox(Double, Double, Double, Double) | Sets the BoundingBox. (Inherited from PdfShading) |