|
Dichiara uno shading a mesh triangolare Gouraud a reticolo PDF 1.3+ (ISO 32000-1 8.7.4.5.5, /ShadingType 5) and wraps it in an inline Pattern Type 2 entry on the page Resources/Pattern . Il renderer auto-triangola ogni coppia di righe adiacenti in una triangle strip, così il chiamante fornisce solo la griglia di vertici - utile quando i dati sorgente vivono già su una griglia di campionamento regolare (terreno, risultati FEA, heatmap scientifiche). Usa RegisterFreeFormGouraudShading quando la triangolazione è irregolare e servono flag per triangolo.
Sintassi Delphi:
function RegisterLatticeFormGouraudShading(XMin, YMin, XMax, YMax: Single; NumComponents: Integer; VerticesPerRow: Integer; const Vertici: array di Extended): AnsiString;
Sintassi C++:
AnsiString RegisterLatticeFormGouraudShading(float XMin, float YMin, float XMax, float YMax, int NumComponents, int VerticesPerRow, const Extended* Vertices, int VertexElementCount);
Descrizione
Lo shading viene emesso come stream indiretto con /ShadingType 5, /BitsPerCoordinate 16, /BitsPerComponent 8 e /VerticesPerRow N. A differenza del Type 4, non c'è un byte di flag per vertice e /BitsPerFlag is absent from the shading dictionary; each vertex occupies 4 + NumComponents bytes (2 big-endian X + 2 big-endian Y + N color components). The /Decode l'array riporta le coordinate a 16 bit al [XMin, XMax] x [YMin, YMax] rettangolo dello spazio utente e ogni componente di colore a [0, 1].
I vertici sono ordinati row-major: i primi VerticesPerRow vertici formano la riga 0, i successivi VerticesPerRow formano la riga 1, e così via. Il renderer collega ogni coppia di righe adiacenti (riga i e riga i+1) in una triangle strip - niente flag, niente elenco esplicito di triangoli. Il numero di Extended valori che passi in Vertices deve essere un multiplo di (2 + NumComponents) * VerticesPerRow e il numero di righe risultante deve essere almeno 2.
XMin, YMin, XMax, YMax - il rettangolo in spazio utente che delimita il reticolo. Questi quattro valori diventano le prime quattro voci di /Decode. Mettili nello stesso spazio coordinate utente in cui dipingerai - per le coordinate schermo di HotPDF Rectangle at (X, Y, W, H) il rettangolo corrispondente dello spazio utente PDF è (X, PageHeight - Y - H) to (X + W, PageHeight - Y).
NumComponents - numero di componenti di colore per vertice. Passa 1 per DeviceGray, 3 per DeviceRGB o 4 for DeviceCMYK. Any other value raises an exception.
VerticesPerRow - number of vertices N per lattice row, N >= 2. The dictionary entry /VerticesPerRow prende questo valore alla lettera. Il numero di righe M si deduce dalla lunghezza dell'array come VertexCount / VerticesPerRow e deve essere almeno 2.
Vertices - array flat di Extended valori in (X, Y, c1...cN) order per vertex, repeated row-major (row 0 first, then row 1, ...). Coordinates are clamped to [XMin, XMax] x [YMin, YMax] and quantised to 16-bit integers; color components are clamped to [0, 1] e quantizzati a interi a 8 bit.
Valore restituito: an auto-generated pattern name (Sh1, Sh2, ...) registered on the current page's Resources/Pattern del dizionario. Restituisce una stringa vuota quando StrictVersionLock è attivo e la Version is below PDF 1.3 (otherwise the document version auto-bumps to 1.3).
Esempio di codice
// 3x3 lattice over a 200x200 quad. The renderer auto-triangulates
// adjacent rows into a triangle strip, giving 4 cells x 2 triangles
// = 8 triangles. Colour layout (visual):
//
// row 0 (top, Y=YMax): red yellow green
// row 1 (mid): magenta gray cyan
// row 2 (bot, Y=YMin): blue purple orange
var
Doc: THotPDF;
PatName: AnsiString;
Verts: array[0..44] of Extended; // 9 vertices x 5 floats each
H, XMin, YMin, XMax, YMax, XMid, YMid: Single;
begin
Doc := THotPDF.Create(nil);
try
Doc.Version := pdf14;
Doc.BeginDoc;
H := Doc.CurrentPage.Height;
XMin := 0; YMin := H - 200; XMax := 200; YMax := H;
XMid := (XMin + XMax) / 2;
YMid := (YMin + YMax) / 2;
// row 0 (Y=YMax): red - yellow - green
Verts[ 0] := XMin; Verts[ 1] := YMax; Verts[ 2] := 1.0; Verts[ 3] := 0.0; Verts[ 4] := 0.0;
Verts[ 5] := XMid; Verts[ 6] := YMax; Verts[ 7] := 1.0; Verts[ 8] := 1.0; Verts[ 9] := 0.0;
Verts[10] := XMax; Verts[11] := YMax; Verts[12] := 0.0; Verts[13] := 1.0; Verts[14] := 0.0;
// row 1 (Y mid): magenta - gray - cyan
Verts[15] := XMin; Verts[16] := YMid; Verts[17] := 1.0; Verts[18] := 0.0; Verts[19] := 1.0;
Verts[20] := XMid; Verts[21] := YMid; Verts[22] := 0.5; Verts[23] := 0.5; Verts[24] := 0.5;
Verts[25] := XMax; Verts[26] := YMid; Verts[27] := 0.0; Verts[28] := 1.0; Verts[29] := 1.0;
// row 2 (Y=YMin): blue - purple - orange
Verts[30] := XMin; Verts[31] := YMin; Verts[32] := 0.0; Verts[33] := 0.0; Verts[34] := 1.0;
Verts[35] := XMid; Verts[36] := YMin; Verts[37] := 0.5; Verts[38] := 0.0; Verts[39] := 0.5;
Verts[40] := XMax; Verts[41] := YMin; Verts[42] := 1.0; Verts[43] := 0.5; Verts[44] := 0.0;
PatName := Doc.RegisterLatticeFormGouraudShading(
XMin, YMin, XMax, YMax, 3, 3, Verts);
Doc.CurrentPage.SetFillPattern(PatName);
Doc.CurrentPage.Rectangle(0, 0, 200, 200);
Doc.CurrentPage.Fill;
Doc.EndDoc;
finally
Doc.Free;
end;
end;
Vedi anche:
RegisterFreeFormGouraudShading, RegisterDeviceN, RegisterSeparation, RegisterLabColorSpace, Version, Supporto dei filtri PDF
|