|
PDF 1.3+ tensor product patch mesh shading(ISO 32000-1 8.7.4.5.7, /ShadingType 7)을 선언하고 page Resources/Pattern dictionary의 inline Pattern Type 2 entry로 감쌉니다. 각 patch는 bicubic Bezier control point p[i][j]의 전체 4 x 4 grid(12 boundary + 4 interior)와 corner당 하나의 color를 가집니다. RegisterCoonsPatchMesh(Type 6)가 interior shape를 표현할 수 없을 때 사용하십시오. 예를 들어 SVG mesh-gradient round-trip이나 patch interior를 굽히기 위해 추가 네 control point가 필요한 artwork에 적합합니다
Delphi 구문:
function RegisterTensorProductPatchMesh(XMin, YMin, XMax, YMax: Single; NumComponents: Integer; const Patches: array of Extended): AnsiString;
C++ 구문:
AnsiString RegisterTensorProductPatchMesh(float XMin, float YMin, float XMax, float YMax, int NumComponents, const Extended* Patches, int PatchesElementCount);
설명
Shading은 /ShadingType 7, /BitsPerCoordinate 16, /BitsPerComponent 8, /BitsPerFlag 8을 가진 indirect stream으로 emit됩니다. 각 patch는 1 flag byte(independent patch이므로 항상 0), 16 control point(각 4 byte: 2 big-endian X + 2 big-endian Y, 아래 설명된 spec stream order), 4 corner color(각 NumComponents byte)로 pack되며 patch당 총 1 + 64 + 4 * NumComponents byte입니다
16 control point는 p[i][j] 4 x 4 grid를 이루며, i는 row index(0 = visual top / YMax, 3 = visual bottom / YMin), j는 column index(0 = left / XMin, 3 = right / XMax)입니다. Spec stream order(Table 88)는 먼저 12 boundary point를 clockwise로 순회하고(top row LtoR, right column TtoB, bottom row RtoL, left column BtoT), 이어 top-left interior point에서 시작하는 clockwise 순서로 4 interior point p[1][1], p[1][2], p[2][2], p[2][1]를 나열합니다. User-supplied Patches array는 이 순서를 그대로 따릅니다
16개 control point가 모두 regular 1/3 / 2/3 lattice(각 edge의 1/3 / 2/3 위치에 boundary point, 내부 (1/3, 1/3) / (2/3, 1/3) / (2/3, 2/3) / (1/3, 2/3) grid intersection에 interior point)에 놓이면 bicubic Bezier surface는 flat plane으로, color interpolation은 bilinear로 축약됩니다. 이는 straight edge를 가진 RegisterCoonsPatchMesh 또는 네 corner vertex를 가진 RegisterFreeFormGouraudShading과 시각적으로 동일합니다
XMin, YMin, XMax, YMax - encoded coordinate를 둘러싸는 user-space rectangle입니다. 이 네 값은 /Decode의 처음 네 entry가 됩니다. 실제로 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는 32 + 4 * NumComponents 값을 제공합니다. Spec stream order의 16 control point에 대한 32 float(X, Y, X, Y, ..., 16 pair) 뒤에 corner color용 4 * NumComponents float(p[0][0] / p[0][3] / p[3][3] / p[3][0], Coons cyclic order와 일치)가 옵니다. 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 bilinear-equivalent tensor-product patch covering a 200x200
// quad. All 16 control points sit on the 1/3 / 2/3 lattice =>
// bicubic surface degenerates to bilinear; four corner colours
// red / green / yellow / blue
var
Doc: THotPDF;
PatName: AnsiString;
Patches: array[0..43] of Extended; // 16 ctrl pts * 2 + 4 corners * 3 = 44
H, XMin, YMin, XMax, YMax: Single;
XThird, X2Third, YThird, Y2Third: 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;
XThird := XMin + 200 / 3; X2Third := XMin + 2 * 200 / 3;
YThird := YMin + 200 / 3; Y2Third := YMin + 2 * 200 / 3;
// Spec stream order: top row LtoR, right column TtoB, bottom row RtoL,
// left column BtoT, then interior 4 clockwise starting at p[1][1]
Patches[ 0] := XMin; Patches[ 1] := YMax; // p[0][0] TL
Patches[ 2] := XThird; Patches[ 3] := YMax; // p[0][1]
Patches[ 4] := X2Third; Patches[ 5] := YMax; // p[0][2]
Patches[ 6] := XMax; Patches[ 7] := YMax; // p[0][3] TR
Patches[ 8] := XMax; Patches[ 9] := Y2Third; // p[1][3]
Patches[10] := XMax; Patches[11] := YThird; // p[2][3]
Patches[12] := XMax; Patches[13] := YMin; // p[3][3] BR
Patches[14] := X2Third; Patches[15] := YMin; // p[3][2]
Patches[16] := XThird; Patches[17] := YMin; // p[3][1]
Patches[18] := XMin; Patches[19] := YMin; // p[3][0] BL
Patches[20] := XMin; Patches[21] := YThird; // p[2][0]
Patches[22] := XMin; Patches[23] := Y2Third; // p[1][0]
Patches[24] := XThird; Patches[25] := Y2Third; // p[1][1]
Patches[26] := X2Third; Patches[27] := Y2Third; // p[1][2]
Patches[28] := X2Third; Patches[29] := YThird; // p[2][2]
Patches[30] := XThird; Patches[31] := YThird; // p[2][1]
// 4 corner colours at p[0][0] / p[0][3] / p[3][3] / p[3][0]
Patches[32] := 1.0; Patches[33] := 0.0; Patches[34] := 0.0; // red
Patches[35] := 0.0; Patches[36] := 1.0; Patches[37] := 0.0; // green
Patches[38] := 1.0; Patches[39] := 1.0; Patches[40] := 0.0; // yellow
Patches[41] := 0.0; Patches[42] := 0.0; Patches[43] := 1.0; // blue
PatName := Doc.RegisterTensorProductPatchMesh(
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
RegisterCoonsPatchMesh, RegisterFreeFormGouraudShading, RegisterLatticeFormGouraudShading, Version, PDF Filter Support
|