|
ประกาศ tensor product patch mesh shading แบบ PDF 1.3+ (ISO 32000-1 8.7.4.5.7, /ShadingType 7) แล้วหุ้มด้วยรายการ Pattern Type 2 แบบ inline บนพจนานุกรม Resources/Pattern ของหน้า patch แต่ละชิ้นเป็นกริด 4 x 4 เต็มของจุดควบคุม bicubic Bezier p[i][j] (ขอบ 12 + ด้านใน 4) พร้อมสีประจำมุมหนึ่งสี ใช้ตัวนี้เมื่อ RegisterCoonsPatchMesh (Type 6) แสดงรูปทรงด้านในไม่ได้ - เช่น การวนกลับ SVG mesh-gradient และงานกราฟิกที่ต้องใช้จุดควบคุมเพิ่มอีกสี่จุดเพื่อโค้งด้านในของ patch
ไวยากรณ์ Delphi:
function RegisterTensorProductPatchMesh(XMin, YMin, XMax, YMax: Single; NumComponents: Integer; const Patches: array of Extended): AnsiString;
ไวยากรณ์ C++:
คำอธิบาย
shading ถูกปล่อยเป็น indirect stream เดี่ยวพร้อม /ShadingType 7, /BitsPerCoordinate 16, /BitsPerComponent 8 และ /BitsPerFlag 8 patch แต่ละชิ้นแพ็กเป็น 1 ไบต์ flag (เป็น 0 เสมอสำหรับ patch อิสระ) ตามด้วยจุดควบคุม 16 จุด (จุดละ 4 ไบต์: X 2 ไบต์ big-endian + Y 2 ไบต์ big-endian เรียงตามลำดับ stream ตามสเปกที่อธิบายไว้ด้านล่าง) และสีมุม 4 สี (ละ NumComponents ไบต์) รวม 1 + 64 + 4 * NumComponents ไบต์ต่อ patch
จุดควบคุม 16 จุดจัดเป็นกริด 4 x 4 p[i][j] โดย i = ดัชนีแถว (0 = บนเชิงภาพ / YMax, 3 = ล่างเชิงภาพ / YMin) และ j = ดัชนีคอลัมน์ (0 = ซ้าย / XMin, 3 = ขวา / XMax) ลำดับใน stream ตามสเปก (Table 88) จะไล่จุดขอบ 12 จุดตามเข็มนาฬิกาก่อน (แถวบนซ้ายไปขวา, คอลัมน์ขวาบนลงล่าง, แถวล่างขวาไปซ้าย, คอลัมน์ซ้ายล่างขึ้นบน) แล้วจึงระบุจุดด้านใน 4 จุดตามเข็มนาฬิกาเริ่มจากจุดด้านในบนซ้าย: p[1][1], p[1][2], p[2][2], p[2][1] array Patches ที่ผู้ใช้ให้มาเรียงตามลำดับนี้แบบตรงตัว
XMin, YMin, XMax, YMax - สี่เหลี่ยมผ้าน้ำพื้นที่ผู้ใช้ที่กำหนดขอบเขตของพิกัดที่เข้ารหัส ค่าทั้งสี่นี้จะกลายเป็นสี่รายการแรกของ /Decode วางพิกัดเหล่านี้ไว้ในพิกัดพื้นที่ผู้ใช้เดียวกับที่คุณจะระบายสีลงไป สำหรับวัตถุ Rectangle บนพิกัดหน้าจอของ HotPDF ที่ (X, Y, W, H) สี่เหลี่ยมผืนผ้าพื้นที่ผู้ใช้ PDF ที่ตรงกันคือ (X, PageHeight - Y - H) ไปยัง (X + W, PageHeight - Y)
XMin, YMin, XMax, YMax - สี่เหลี่ยม user space ที่ล้อมพิกัดที่เข้ารหัส สี่ค่านี้กลายเป็นสี่รายการแรกของ /Decode วางค่าเหล่านี้ในพิกัด user space เดียวกับที่จะวาดจริง - สำหรับ Rectangle พิกัดหน้าจอของ HotPDF ที่ (X, Y, W, H) สี่เหลี่ยม user space ของ PDF ที่ตรงกันคือจาก (X, PageHeight - Y - H) ถึง (X + W, PageHeight - Y)
NumComponents - จำนวน color component ต่อหนึ่งมุม ส่ง 1 สำหรับ DeviceGray, 3 สำหรับ DeviceRGB หรือ 4 สำหรับ DeviceCMYK ค่าอื่นจะ raise exception
Patches - array แบนของค่า Extended patch แต่ละชิ้นกินค่า 32 + 4 * NumComponents ตัว: 32 จำนวนจริงสำหรับจุดควบคุม 16 จุด (X, Y, X, Y, ..., 16 คู่ตามลำดับ stream ของสเปก) ตามด้วย 4 * NumComponents จำนวนจริงสำหรับสีมุม (ที่ p[0][0] / p[0][3] / p[3][3] / p[3][0] ตรงกับลำดับวนกลับแบบ Coons) ความยาว array ต้องเป็นจำนวนเท่าบวกของ stride นี้ patch ที่ปล่อยทุกชิ้นมี flag = 0 (patch อิสระ) flag ต่อเนื่อง 1 / 2 / 3 (แชร์ขอบกับ patch ก่อนหน้า) ไม่เปิดเผยใน overload สะดวกตัวนี้
ค่าที่ส่งกลับ: ชื่อ pattern ที่สร้างอัตโนมัติ (Sh1, Sh2, ...) ซึ่งลงทะเบียนไว้ใน dictionary Resources/Pattern ของหน้าปัจจุบัน คืนค่า string ว่างเมื่อเปิด StrictVersionLock อยู่และ Version ที่ใช้งานต่ำกว่า PDF 1.3 (ถ้าไม่ล็อก เวอร์ชันเอกสารจะขยับขึ้นเป็น 1.3 ให้เอง)
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;
ดูเพิ่มเติม
ดูเพิ่มเติม
|