|
Dichiara uno shading a mesh triangolare Gouraud free-form PDF 1.3+ (ISO 32000-1 8.7.4.5.4, /ShadingType 4) and wraps it in an inline Pattern Type 2 entry on the page Resources/Pattern . Usa il nome pattern restituito con THPDFPage.SetFillPattern oppure THPDFPage.SetStrokePattern to paint a vector gradient whose color varies smoothly across each triangle.
Sintassi Delphi:
function RegisterFreeFormGouraudShading(XMin, YMin, XMax, YMax: Single; NumComponents: Integer; const Vertici: array di Extended): AnsiString;
Sintassi C++:
AnsiString RegisterFreeFormGouraudShading(float XMin, float YMin, float XMax, float YMax, int NumComponents, const Extended* Vertices, int VertexElementCount);
Descrizione
Lo shading viene emesso come un singolo stream indiretto con /ShadingType 4, /BitsPerCoordinate 16, /BitsPerComponent 8 e /BitsPerFlag 8. Ogni vertice è impacchettato in ordine di stream come 8 + NumComponents − 3 bytes - a 1-byte flag (always 0 for independent triangles), 2 big-endian bytes for the X coordinate, 2 big-endian bytes for the Y coordinate, and NumComponents componenti colore a 8 bit. L'argomento /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 vengono consumati tre alla volta come triangoli indipendenti. Il numero di Extended valori che passi in Vertices devono essere esattamente (2 + NumComponents) * 3 * TriangleCount; the helper raises an exception when the array length is not a multiple of the stride or when the vertex count is not a multiple of three.
XMin, YMin, XMax, YMax - il rettangolo in spazio utente che delimita la mesh. Questi quattro valori diventano le prime quattro voci di /Decode così le coordinate dei vertici codificate a 16 bit tornano allo spazio utente PDF. Mettile 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. The /ColorSpace dello shading risultante viene impostato di conseguenza.
Vertices - array flat di Extended valori in (X, Y, c1...cN) ordine, ripetuto per ogni vertice. Le coordinate sono limitate a [XMin, XMax] x [YMin, YMax] box and quantised to 16-bit integers; color components are clamped to [0, 1] e quantizzati a interi a 8 bit. I triangoli adiacenti che devono condividere un lato devono ripetere alla lettera i vertici condivisi perché lo shading registrato usa flag 0 per ogni vertice (triangoli indipendenti).
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
// Four-corner colour quad split into two independent triangles
// along the top-left -> bot-right diagonal. The colours blend
// smoothly across the mesh; the diagonal is the ridge where the
// two triangles meet
//
// top-left red -- top-right green
// | |
// bot-left blue -- bot-right yellow
var
Doc: THotPDF;
PatName: AnsiString;
Verts: array[0..29] of Extended;
H, XMin, YMin, XMax, YMax: 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;
// triangle A: top-left red, top-right green, bot-right yellow
Verts[ 0] := XMin; Verts[ 1] := YMax; Verts[ 2] := 1.0; Verts[ 3] := 0.0; Verts[ 4] := 0.0;
Verts[ 5] := XMax; Verts[ 6] := YMax; Verts[ 7] := 0.0; Verts[ 8] := 1.0; Verts[ 9] := 0.0;
Verts[10] := XMax; Verts[11] := YMin; Verts[12] := 1.0; Verts[13] := 1.0; Verts[14] := 0.0;
// triangle B: top-left red, bot-right yellow, bot-left blue
Verts[15] := XMin; Verts[16] := YMax; Verts[17] := 1.0; Verts[18] := 0.0; Verts[19] := 0.0;
Verts[20] := XMax; Verts[21] := YMin; Verts[22] := 1.0; Verts[23] := 1.0; Verts[24] := 0.0;
Verts[25] := XMin; Verts[26] := YMin; Verts[27] := 0.0; Verts[28] := 0.0; Verts[29] := 1.0;
PatName := Doc.RegisterFreeFormGouraudShading(
XMin, YMin, XMax, YMax, 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:
RegisterDeviceN, RegisterSeparation, RegisterLabColorSpace, Version, Supporto dei filtri PDF
|