NewRGBFreeFormTriangleMesh
Shading, Graphics
Description
Creates a free-form Gouraud-shaded triangle mesh, PDF shading type 4, and registers it under ShaderName in DeviceRGB colour. Vertices are consumed in groups of three, each group describing one triangle whose corner colours interpolate across its surface. Every triangle is emitted independently with a start-vertex flag, so no edge sharing between triangles is required
Syntax
Delphi
Function TPDFlib.NewRGBFreeFormTriangleMesh(Const ShaderName: WideString;
Const Vertices: Array Of TPLMeshVertex; 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 colour components in the range 0 to 1; the length must be at least 3 and a multiple of 3 |
| BitsPerCoordinate | Quantisation bits for vertex coordinates, between 1 and 32 |
| BitsPerComponent | Quantisation bits per colour 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, fewer than one complete triangle was supplied, 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.5). For gradient shadings without vertex data see NewRGBAxialShader
Example
SetLength(Vertices, 3);
Vertices[0].X:= 100; Vertices[0].Y:= 100;
Vertices[0].R:= 1; Vertices[0].G:= 0; Vertices[0].B:= 0;
Vertices[1].X:= 400; Vertices[1].Y:= 100;
Vertices[1].R:= 0; Vertices[1].G:= 1; Vertices[1].B:= 0;
Vertices[2].X:= 250; Vertices[2].Y:= 350;
Vertices[2].R:= 0; Vertices[2].G:= 0; Vertices[2].B:= 1;
PDF.NewRGBFreeFormTriangleMesh('tri', Vertices, 16, 8,
100, 100, 400, 350);
PDF.SetFillShader('tri');