NewRGBLatticeTriangleMesh
Shading, Graphics
Description
Creates a lattice-form Gouraud-shaded triangle mesh, PDF shading type 5, and registers it under ShaderName in DeviceRGB color. Vertices are emitted row by row with VerticesPerRow entries per row, the lattice is triangulated by the conforming reader, and the vertex stream carries no edge flags
Syntax
Delphi
Function TPDFlib.NewRGBLatticeTriangleMesh(Const ShaderName: WideString;
Const Vertices: Array Of TPLMeshVertex; VerticesPerRow: Integer;
BitsPerCoordinate, BitsPerComponent: Integer;
Const BoundsX0, BoundsY0, BoundsX1, BoundsY1: Double): Integer;Parameters
| ShaderName | Name the shader is registered under; pass it to SetFillShader or SetLineShader to paint with the mesh |
|---|---|
| Vertices | Array of TPLMeshVertex records (X, Y, R, G, B) with color components in the range 0 to 1, ordered row by row; the length must be an exact multiple of VerticesPerRow and hold at least two rows |
| VerticesPerRow | Number of vertices per lattice row, at least 2 |
| BitsPerCoordinate | Quantization bits for vertex coordinates, between 1 and 32 |
| BitsPerComponent | Quantization bits per color component, between 1 and 16 |
| BoundsX0, BoundsY0, BoundsX1, BoundsY1 | Decode rectangle that maps the packed vertex coordinates into shading coordinate space |
Return values
| 0 | The mesh was not created, because no document is selected, VerticesPerRow is below 2, the vertex count is not a multiple of VerticesPerRow or holds fewer than two rows, or a bits parameter is out of range |
|---|---|
| 1 | The mesh was registered under ShaderName |
Remarks
Coordinates follow the library top-left origin system and are translated internally (ISO 32000-1 §8.7.4.5.6). A lattice needs fewer vertices than NewRGBFreeFormTriangleMesh for grid-aligned color fields because shared vertices are stated once
Example
// 3 columns x 2 rows of color samples
SetLength(Vertices, 6);
for I:= 0 to High(Vertices) do
Begin
Vertices[I].X:= 100+ (I mod 3)* 150;
Vertices[I].Y:= 100+ (I div 3)* 150;
Vertices[I].R:= I/ 5; Vertices[I].G:= 0.5; Vertices[I].B:= 1- I/ 5;
End;
PDF.NewRGBLatticeTriangleMesh('grid', Vertices, 3, 16, 8,
100, 100, 400, 250);
PDF.SetFillShader('grid');