NewRGBLatticeTriangleMesh

Shading, Graphics

Description

Creates a lattice-form Gouraud-shaded triangle mesh, PDF shading type 5, and registers it under ShaderName in DeviceRGB colour. 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

ShaderNameName the shader is registered under; pass it to SetFillShader or SetLineShader to paint with the mesh
VerticesArray of TPLMeshVertex records (X, Y, R, G, B) with colour 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
VerticesPerRowNumber of vertices per lattice row, at least 2
BitsPerCoordinateQuantisation bits for vertex coordinates, one of 1, 2, 4, 8, 12, 16, 24 or 32
BitsPerComponentQuantisation bits per colour component, one of 1, 2, 4, 8, 12 or 16
BoundsX0, BoundsY0, BoundsX1, BoundsY1Decode rectangle that maps the packed vertex coordinates into shading coordinate space

Return values

0The 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 not one of the permitted values
1The 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 colour 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');