|
מצהיר על Coons patch mesh shading עבור PDF 1.3+ (ISO 32000-1 8.7.4.5.6, /ShadingType 6) ועוטף אותו ב-entry Pattern Type 2 inline במילון Resources/Pattern של העמוד. כל patch תחום על ידי ארבע עקומות cubic Bezier ונושא צבע אחד לכל פינה; ה-renderer מתאים את משטח Coons בין ארבעת הקצוות, ויוצר quad נושא צבע עם עקמומיות שרירותית. השתמש בכך כאשר meshes של משולשים בעלי קצוות ישרים, RegisterFreeFormGouraudShading או RegisterLatticeFormGouraudShading, היו צריכים משולשים רבים כדי לקרב גבולות מעוקלים, כגון foil ו-gradients מתכתיים על נתיבים מכופפים, gradient meshes שמקורם ב-SVG וכל quad עם קצוות מעוקלים
Delphi syntax:
function RegisterCoonsPatchMesh(XMin, YMin, XMax, YMax: Single; NumComponents: Integer; const Patches: array of Extended): AnsiString;
C++ syntax:
AnsiString RegisterCoonsPatchMesh(float XMin, float YMin, float XMax, float YMax, int NumComponents, const Extended* Patches, int PatchesElementCount);
תיאור
ה-shading נפלט כ-stream indirect עם /ShadingType 6, /BitsPerCoordinate 16, /BitsPerComponent 8 ו-/BitsPerFlag 8. כל patch נארז כ-flag byte אחד, תמיד 0 עבור patches עצמאיים, ואחריו 12 נקודות בקרה, כל אחת 4 bytes שהם 2 big-endian X + 2 big-endian Y, ו-4 צבעי פינה, כל אחד NumComponents bytes. סך הכל 1 + 48 + 4 * NumComponents bytes לכל patch. מערך /Decode ממפה את קואורדינטות 16-bit בחזרה למלבן user-space שסופק [XMin, XMax] x [YMin, YMax] וכל רכיב צבע בחזרה אל [0, 1]
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 - מלבן user-space שתוחם את הקואורדינטות המקודדות. ארבעת הערכים האלה הופכים לארבעת entries הראשונים של /Decode. נקודות בקרה מחוץ למלבן זה מוגבלות בזמן encoding. הצב אותן באותן קואורדינטות user-space שבהן תצייר; עבור Rectangle בקואורדינטות מסך של HotPDF ב-(X, Y, W, H), מלבן user-space התואם ב-PDF הוא מ-(X, PageHeight - Y - H) עד (X + W, PageHeight - Y)
NumComponents - מספר רכיבי הצבע לכל פינה. העבר 1 עבור DeviceGray, 3 עבור DeviceRGB או 4 עבור DeviceCMYK. כל ערך אחר מעלה חריגה
Patches - מערך שטוח של ערכי Extended. כל patch תורם 24 + 4 * NumComponents ערכים: 24 floats עבור 12 נקודות הבקרה, X, Y, X, Y וכן הלאה, 12 זוגות בסדר c1..c12 בכיוון השעון, ולאחריהם 4 * NumComponents floats עבור צבעי הפינות, כאשר corner 1 / 2 / 3 / 4 = c1 / c4 / c7 / c10 בסדר מחזורי. אורך המערך חייב להיות כפולה חיובית של stride זה. כל patches שנפלטים נושאים flag = 0, כלומר patch עצמאי; continuation flags 1 / 2 / 3, שיתוף קצה עם patch קודם, אינם נחשפים ב-overload convenience זה
הערך המוחזר: שם pattern שנוצר אוטומטית, כגון Sh1, Sh2 וכן הלאה, ונרשם במילון Resources/Pattern של העמוד הנוכחי. מוחזרת מחרוזת ריקה כאשר StrictVersionLock מופעל וה-Version הפעילה נמוכה מ-PDF 1.3; אחרת גרסת המסמך עולה אוטומטית ל-1.3
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
|