THotPDF.RegisterCoonsPatchMesh Metodo THotPDF.RegisterCoonsPatchMesh Metodo THotPDF.RegisterCoonsPatchMesh Metodo THotPDF.RegisterCoonsPatchMesh Metodo THotPDF.RegisterCoonsPatchMesh Metodo THotPDF.RegisterCoonsPatchMesh Metodo THotPDF.RegisterCoonsPatchMesh Metodo

 

THotPDF.RegisterCoonsPatchMesh

THotPDF

 

Top

Dichiara uno shading a mesh di patch Coons PDF 1.3+ (ISO 32000-1 8.7.4.5.6, /ShadingType 6) and wraps it in an inline Pattern Type 2 entry on the page Resources/Pattern dictionary. Each patch is bounded by four cubic Bezier curves and carries one color per corner; the renderer fits the Coons surface between the four edges, giving an arbitrarily curved color-bearing quad. Use this when straight-edge triangle meshes (RegisterFreeFormGouraudShading, RegisterLatticeFormGouraudShadingavrebbero bisogno di molti triangoli per approssimare i bordi curvi - gradienti foil e metallici su percorsi curvi, mesh di gradienti derivate da SVG e qualsiasi quadrilatero con lati curvi.

 

Sintassi Delphi:

function RegisterCoonsPatchMesh(XMin, YMin, XMax, YMax: Single; NumComponents: Integer; const Patch: array di Extended): AnsiString;

 

Sintassi C++:

AnsiString RegisterCoonsPatchMesh(float XMin, float YMin, float XMax, float YMax, int NumComponents, const Extended* Patches, int PatchesElementCount);

 

Descrizione

Lo shading viene emesso come stream indiretto con /ShadingType 6, /BitsPerCoordinate 16, /BitsPerComponent 8 e /BitsPerFlag 8. Each patch is packed as 1 flag byte (always 0 for independent patches) followed by 12 control points (each 4 bytes: 2 big-endian X + 2 big-endian Y) and 4 corner colors (each NumComponents bytes), totalling 1 + 48 + 4 * NumComponents byte per patch. Il /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 12 punti di controllo sono numerati c1..c12 in senso orario attorno al confine della patch partendo dall'angolo 1. I quattro angoli sono c1 / c4 / c7 / c10, e gli otto rimanenti (c2, c3 tra c1 e c4; c5, c6 tra c4 e c7; c8, c9 tra c7 e c10; c11, c12 tra c10 e c1) sono le maniglie Bezier interne di ogni lato cubico. Quando le maniglie interne siedono a 1/3 e 2/3 lungo la retta tra angoli adiacenti, la superficie di Coons degenera in interpolazione bilineare - visivamente equivalente a una mesh Type 4 a 4 vertici.

 

XMin, YMin, XMax, YMax - il rettangolo in spazio utente che delimita le coordinate codificate. Questi quattro valori diventano le prime quattro voci di /Decode. I punti di controllo fuori da questo rettangolo vengono limitati in fase di codifica. 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 angolo. Passa 1 per DeviceGray, 3 per DeviceRGB o 4 for DeviceCMYK. Any other value raises an exception.

Patches - array flat di Extended . Ogni patch contribuisce 24 + 4 * NumComponents values: 24 floats for the 12 control points (X, Y, X, Y, ..., 12 pairs in c1..c12 clockwise order) followed by 4 * NumComponents float per i colori d'angolo (angolo 1 / 2 / 3 / 4 = c1 / c4 / c7 / c10 in ordine ciclico). La lunghezza dell'array deve essere un multiplo positivo di questo passo. Tutte le patch emesse portano flag = 0 (patch indipendente); i flag di continuazione 1 / 2 / 3 (condivisione del lato con la patch precedente) non sono esposti in questo overload di comodo.

 

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

// Single straight-edge Coons patch covering a 200x200 quad. Inner
// control points placed at 1/3 / 2/3 along each edge => bilinear
// surface. Four corner colours = red / green / yellow / blue
var
  Doc: THotPDF;
  PatName: AnsiString;
  Patches: array[0..35] of Extended;   // 12 ctrl pts * 2 + 4 corners * 3 = 36
  H, XMin, YMin, XMax, YMax, W: 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;
    W := 200;
    // c1..c12 clockwise. Inner handles at 1/3 / 2/3 => straight edges
    Patches[ 0] := XMin;            Patches[ 1] := YMax;             // c1  TL
    Patches[ 2] := XMin + W / 3;    Patches[ 3] := YMax;             // c2
    Patches[ 4] := XMin + 2*W / 3;  Patches[ 5] := YMax;             // c3
    Patches[ 6] := XMax;            Patches[ 7] := YMax;             // c4  TR
    Patches[ 8] := XMax;            Patches[ 9] := YMax - W / 3;     // c5
    Patches[10] := XMax;            Patches[11] := YMax - 2*W / 3;   // c6
    Patches[12] := XMax;            Patches[13] := YMin;             // c7  BR
    Patches[14] := XMax - W / 3;    Patches[15] := YMin;             // c8
    Patches[16] := XMax - 2*W / 3;  Patches[17] := YMin;             // c9
    Patches[18] := XMin;            Patches[19] := YMin;             // c10 BL
    Patches[20] := XMin;            Patches[21] := YMin + W / 3;     // c11
    Patches[22] := XMin;            Patches[23] := YMin + 2*W / 3;   // c12
    // 4 corner colours (c1 / c4 / c7 / c10)
    Patches[24] := 1.0; Patches[25] := 0.0; Patches[26] := 0.0;  // red
    Patches[27] := 0.0; Patches[28] := 1.0; Patches[29] := 0.0;  // green
    Patches[30] := 1.0; Patches[31] := 1.0; Patches[32] := 0.0;  // yellow
    Patches[33] := 0.0; Patches[34] := 0.0; Patches[35] := 1.0;  // blue
    PatName := Doc.RegisterCoonsPatchMesh(XMin, YMin, XMax, YMax, 3, Patches);
    Doc.CurrentPage.SetFillPattern(PatName);
    Doc.CurrentPage.Rectangle(0, 0, 200, 200);
    Doc.CurrentPage.Fill;
    Doc.EndDoc;
  finally
    Doc.Free;
  end;
end;

 

Vedi anche:

RegisterFreeFormGouraudShading, RegisterLatticeFormGouraudShading, RegisterDeviceN, Version, Supporto dei filtri PDF