# PdfLatticeTriangleMeshShading Class

Type 5 shadings (lattice-form Gouraud-shaded triangle meshes) are similar to PdfFreeTriangleMeshShading, but instead of using free-form geometry, their vertices are arranged in a *pseudorectangular lattice*, which is topologically equivalent to a rectangular grid. The vertices are organized into rows, which need not be geometrically linear.

`public sealed class PdfLatticeTriangleMeshShading : PdfMeshShading, IEnumerable<PdfMeshTriangle>, IEnumerable`

```
Public NotInheritable Class PdfLatticeTriangleMeshShading
Inherits PdfMeshShading
Implements IEnumerable(Of PdfMeshTriangle), IEnumerable
```

- Inheritance:
- PdfLatticeTriangleMeshShading

### Constructors

#### PdfLatticeTriangleMeshShading(Int32, IList<PdfFunction>, PdfColorSpace)

Initializes a new instance of the PdfLatticeTriangleMeshShading class with the specified number of vertices in each row of the lattice and an optional ColorSpace.

The Add(PdfMeshVertex) method must be used to populate a mesh with `verticesPerRow`

vertices in each row of the lattice.

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, and Decode entries and to serialize the mesh data to the underlying stream.

`public PdfLatticeTriangleMeshShading(int verticesPerRow, IList<PdfFunction> function = null, PdfColorSpace colorSpace = null)`

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

##### Parameters

`verticesPerRow`

- Int32

The number of vertices in each row of the lattice; the value shall be greater than or equal to 2. The number of rows need not be specified, but the number of added vertices should be such that the lattice contains at least 2 rows (the number of added vertices should be at least 2 * `verticesPerRow`

and should be a multiple of `verticesPerRow`

).

`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

The `verticesPerRow`

must greater than or equal to 2.

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

Initializes a new instance of the PdfLatticeTriangleMeshShading class that has the specified number of vertices in each row of the lattice, mesh data serialization settings and, optionally, ColorSpace.

The Add(PdfMeshVertex) method must be used to populate a mesh with `verticesPerRow`

vertices in each row of the lattice.

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 PdfLatticeTriangleMeshShading(int verticesPerRow, int bitsPerCoordinate, int bitsPerComponent, PdfNumberRange decodeX, PdfNumberRange decodeY, IList<PdfFunction> function = null, PdfColorSpace colorSpace = null)`

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

##### Parameters

`verticesPerRow`

- Int32

The number of vertices in each row of the lattice; the value shall be greater than or equal to 2. The number of rows need not be specified, but the number of added vertices should be such that the lattice contains at least 2 rows (the number of added vertices should be at least 2 * `verticesPerRow`

and should be a multiple of `verticesPerRow`

).

`bitsPerCoordinate`

- Int32

The number of bits used to represent each vertex 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.

`decodeX`

- PdfNumberRange

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

`decodeY`

- PdfNumberRange

A PdfNumberRange specifying how to map vertical component of vertex 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

The `verticesPerRow`

must greater than or equal to 2.

`bitsPerCoordinate`

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

`bitsPerComponent`

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

### Properties

#### ShadingType

Gets the LatticeTriangleMesh value.

`public override PdfShadingType ShadingType { get; }`

`Public Overrides ReadOnly Property ShadingType As PdfShadingType`

##### Property Value

The LatticeTriangleMesh value.

##### Overrides

#### VerticesPerRow

*(Required)* The number of vertices in each row of the lattice; the value shall be greater than or equal to 2. The number of rows need not be specified, but the number of added vertices should be such that the lattice contains at least 2 rows (the number of added vertices should be at least 2 * VerticesPerRow and should be a multiple of VerticesPerRow).

##### Property Value

The number of vertices in each row of the lattice.

##### Exceptions

Value must be greater than or equal to 2.

##### See Also

### Methods

#### Add(PdfMeshVertex)

Populates a mesh with a vertex.

##### note

This method should be called VerticesPerRow number of times for each row of the lattice and the lattice should contain at least 2 rows.

##### Parameters

`vertex`

- PdfMeshVertex

The vertex.

##### Exceptions

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

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

is true.

The Space of the Color of `vertex`

is not equal to the shading's ColorSpace.

#### GetEnumerator()

Returns an enumerator that iterates PdfMeshTriangles contained in this PdfLatticeTriangleMeshShading.

`public PdfLatticeTriangleMeshShading.Enumerator GetEnumerator()`

`Public Function GetEnumerator As PdfLatticeTriangleMeshShading.Enumerator`

##### Returns

##### Exceptions

The PdfLatticeTriangleMeshShading contains less than two vertices per row.

The PdfLatticeTriangleMeshShading contains less than two rows of vertices.

The PdfLatticeTriangleMeshShading contains an insufficient number of vertices to form a complete lattice. Each row of a complete lattice must contain the same number of vertices (at least two) and there must be at least two rows.

#### Pack(Boolean)

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

`public PdfLatticeTriangleMeshShading Pack(bool resolveSerializationSettings = true)`

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

##### Parameters

`resolveSerializationSettings`

- Boolean

true to set or adjust the mesh data serialization settings (BitsPerCoordinate, BitsPerComponent, 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 PdfLatticeTriangleMeshShading 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) |