THotPDF.RegisterCoonsPatchMesh 메서드

 

THotPDF.RegisterCoonsPatchMesh

THotPDF

 

맨 위

PDF 1.3+ Coons patch mesh shading(ISO 32000-1 8.7.4.5.6, /ShadingType 6)을 선언하고 page Resources/Pattern dictionary의 inline Pattern Type 2 entry로 감쌉니다. 각 patch는 네 cubic Bezier curve로 둘러싸이고 corner당 하나의 color를 가집니다. Renderer는 네 edge 사이에 Coons surface를 맞춰 임의로 휘어진 color-bearing quad를 만듭니다. Straight-edge triangle mesh(RegisterFreeFormGouraudShading, RegisterLatticeFormGouraudShading)가 curved boundary를 근사하려면 많은 triangle이 필요한 경우에 사용하십시오. 예: bent path의 foil 및 metallic gradient, SVG-derived gradient mesh, curved edge가 있는 quad

 

Delphi 구문:

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

 

C++ 구문:

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

 

설명

Shading은 /ShadingType 6, /BitsPerCoordinate 16, /BitsPerComponent 8, /BitsPerFlag 8을 가진 indirect stream으로 emit됩니다. 각 patch는 1 flag byte(independent patch이므로 항상 0), 12 control point(각 4 byte: 2 big-endian X + 2 big-endian Y), 4 corner color(각 NumComponents byte)로 pack되며 patch당 총 1 + 48 + 4 * NumComponents byte입니다. /Decode array는 16-bit coordinate를 제공된 [XMin, XMax] x [YMin, YMax] user-space rectangle로, 각 color component를 [0, 1]로 다시 map합니다

The 12 control points are numbered c1..c12 in clockwise order around the patch boundary starting from corner 1. The four corners are c1 / c4 / c7 / c10, and the remaining eight (c2, c3 between c1 and c4; c5, c6 between c4 and c7; c8, c9 between c7 and c10; c11, c12 between c10 and c1) are the inner Bezier handles of each cubic edge. When the inner handles sit at 1/3 and 2/3 along the straight line between adjacent corners, the Coons surface degenerates to bilinear interpolation - visually equivalent to a 4-vertex Type 4 mesh.

 

XMin, YMin, XMax, YMax - encoded coordinate를 둘러싸는 user-space rectangle입니다. 이 네 값은 /Decode의 처음 네 entry가 됩니다. 이 rectangle 밖의 control point는 encoding time에 clamp됩니다. 실제로 paint할 동일한 user-space coordinate에 배치하십시오. HotPDF screen-coordinate Rectangle(X, Y, W, H)에 대응하는 PDF user-space rectangle은 (X, PageHeight - Y - H)부터 (X + W, PageHeight - Y)까지입니다

NumComponents - corner당 color component 수입니다. DeviceGray는 1, DeviceRGB는 3, DeviceCMYK는 4를 전달하십시오. 다른 값은 exception을 raise합니다

Patches - Extended value의 flat array입니다. 각 patch는 24 + 4 * NumComponents 값을 제공합니다. c1..c12 clockwise order의 12 control point에 대한 24 float(X, Y, X, Y, ..., 12 pair) 뒤에 corner color용 4 * NumComponents float(corner 1 / 2 / 3 / 4 = cyclic order의 c1 / c4 / c7 / c10)가 옵니다. Array length는 이 stride의 positive multiple이어야 합니다. Emit되는 모든 patch는 flag = 0(independent patch)을 가집니다. Continuation flag 1 / 2 / 3(previous patch와 edge sharing)은 이 convenience overload에서 노출되지 않습니다

 

반환 값: current page의 Resources/Pattern dictionary에 등록된 auto-generated pattern name(Sh1, Sh2, ...)입니다. StrictVersionLock이 켜져 있고 active Version이 PDF 1.3보다 낮으면 빈 string을 반환합니다. 그렇지 않으면 document version이 1.3으로 auto-bump됩니다

 

Code Example

// 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;

 

See Also

RegisterFreeFormGouraudShading, RegisterLatticeFormGouraudShading, RegisterDeviceN, Version, PDF Filter Support