|
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 に wrap します。各 patch は bicubic Bezier control points p[i][j] の完全な 4 x 4 grid (12 boundary + 4 interior) と、corner ごとに 1 つの color を持ちます。RegisterCoonsPatchMesh (Type 6) では interior shape を表現できない場合に使用してください。SVG mesh-gradient round-trips や、patch interior を曲げるために追加 4 control points が必要な artwork に向いています
Delphi syntax:
function RegisterTensorProductPatchMesh(XMin, YMin, XMax, YMax: Single; NumComponents: Integer; const Patches: array of Extended): AnsiString;
C++ syntax:
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 として出力されます。各 patch は 1 flag byte (independent patches では常に 0)、16 control points (各 4 bytes: 2 big-endian X + 2 big-endian Y、下記の spec stream order)、4 corner colors (各 NumComponents bytes) の順で pack され、patch ごとに合計 1 + 64 + 4 * NumComponents bytes になります
16 個の control points は 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 points を時計回りに走査し (top row LtoR、right column TtoB、bottom row RtoL、left column BtoT)、次に top-left interior point から時計回りに 4 interior points: p[1][1]、p[1][2]、p[2][2]、p[2][1] を並べます。user-supplied Patches array はこの same order をそのまま follow します
16 個すべての control points が regular 1/3 / 2/3 lattice 上にある場合 (boundary points は各 edge の 1/3 / 2/3、interior points は inner (1/3, 1/3) / (2/3, 1/3) / (2/3, 2/3) / (1/3, 2/3) grid intersections)、bicubic Bezier surface は flat plane に退化し、color interpolation は bilinear に退化します。視覚的には straight edges の RegisterCoonsPatchMesh または 4 corner vertices の RegisterFreeFormGouraudShading と同一です
XMin、YMin、XMax、YMax - encoded coordinates を囲む user-space rectangle です。これら 4 つの values は /Decode の最初の 4 entries になります。この rectangle の外側にある control points は encoding time に clamp されます。描画先と同じ user-space coordinates で指定してください。HotPDF の screen-coordinate Rectangle が (X, Y, W, H) の場合、対応する PDF user-space rectangle は (X, PageHeight - Y - H) から (X + W, PageHeight - Y) です
NumComponents - corner ごとの color component count です。DeviceGray には 1、DeviceRGB には 3、DeviceCMYK には 4 を渡します。それ以外の値は exception を発生させます
Patches - flat Extended array です。各 patch は 32 + 4 * NumComponents values を提供します。16 control points 用の 32 floats (X, Y, X, Y, ...、spec stream order の 16 pairs) に続き、corner colors 用の 4 * NumComponents floats (p[0][0] / p[0][3] / p[3][3] / p[3][0]、Coons cyclic order と一致) が入ります。array length はこの stride の正の倍数でなければなりません。出力されるすべての patches は flag = 0 (independent patch) を持ちます。continuation flags 1 / 2 / 3 (previous patch との edge sharing) はこの convenience overload では公開されません
戻り値: current page の Resources/Pattern dictionary に登録される auto-generated pattern name (Sh1、Sh2、...) です。StrictVersionLock が on で active Version が PDF 1.3 未満の場合は empty 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;
関連項目
RegisterCoonsPatchMesh, RegisterFreeFormGouraudShading, RegisterLatticeFormGouraudShading, Version, PDF Filter Support
|