THotPDF.RegisterTensorProductPatchMesh Method

 

THotPDF.RegisterTensorProductPatchMesh

THotPDF

 

Üst

PDF 1.3+ tensor product patch mesh shading (ISO 32000-1 8.7.4.5.7, /ShadingType 7) bildirir ve bunu sayfanın Resources/Pattern sözlüğünde inline Pattern Type 2 girdisi olarak sarar. Her patch, bicubic Bezier kontrol noktalarından oluşan tam 4 x 4 grid p[i][j] (12 boundary + 4 interior) ve her köşe için bir renk içerir. RegisterCoonsPatchMesh (Type 6) iç şekli ifade edemediğinde kullanın - SVG mesh-gradient round-tripleri ve patch içini bükmek için ek dört kontrol noktasına ihtiyaç duyan her artwork için.

 

Delphi sözdizimi:

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

 

C++ sözdizimi:

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

 

Açıklama

Shading, /ShadingType 7, /BitsPerCoordinate 16, /BitsPerComponent 8 ve /BitsPerFlag 8 ile indirect stream olarak yayılır. Her patch 1 flag byte (independent patchler için her zaman 0), ardından 16 kontrol noktası (her biri 4 byte: 2 big-endian X + 2 big-endian Y, aşağıda açıklanan spec stream sırasıyla) ve 4 köşe rengi (her biri NumComponents byte) olarak paketlenir; patch başına toplam 1 + 64 + 4 * NumComponents byte.

16 kontrol noktası, i = satır indexi (0 = görsel üst / YMax, 3 = görsel alt / YMin) ve j = sütun indexi (0 = sol / XMin, 3 = sağ / XMax) olacak şekilde 4 x 4 grid p[i][j] oluşturur. Spec stream sırası (Table 88) önce 12 boundary noktasını saat yönünde gezer (üst satır LtoR, sağ sütun TtoB, alt satır RtoL, sol sütun BtoT), ardından sol üst interior noktadan başlayarak 4 interior noktayı saat yönünde listeler: p[1][1], p[1][2], p[2][2], p[2][1]. Kullanıcının sağladığı Patches arrayi bu sırayı birebir izler.

16 kontrol noktasının tümü düzenli 1/3 / 2/3 lattice üzerinde olduğunda (her kenar boyunca 1/3 / 2/3 boundary noktaları, iç (1/3, 1/3) / (2/3, 1/3) / (2/3, 2/3) / (1/3, 2/3) grid kesişimlerinde interior noktalar), bicubic Bezier yüzeyi düz bir plane değerine, renk interpolasyonu da bilinear değere dejenere olur - düz kenarlı RegisterCoonsPatchMesh veya dört köşe vertexli RegisterFreeFormGouraudShading ile görsel olarak aynıdır.

 

XMin, YMin, XMax, YMax - encoded koordinatları sınırlayan user-space dikdörtgeni. Bu dört değer /Decode içindeki ilk dört giriş olur. Bunları boyayacağınız aynı user-space koordinatlarına yerleştirin - HotPDF'nin (X, Y, W, H) ekran koordinatlı Rectangle değeri için eşleşen PDF user-space dikdörtgeni (X, PageHeight - Y - H) ile (X + W, PageHeight - Y) arasıdır.

NumComponents - köşe başına renk component sayısı. DeviceGray için 1, DeviceRGB için 3 veya DeviceCMYK için 4 geçirin. Başka her değer exception oluşturur.

Patches - Extended değerlerinden oluşan düz dizi. Her patch 32 + 4 * NumComponents değer katar: 16 kontrol noktası için 32 float (X, Y, X, Y, ..., spesifikasyon stream sırasıyla 16 çift), ardından köşe renkleri için 4 * NumComponents float (p[0][0] / p[0][3] / p[3][3] / p[3][0] konumlarında, Coons döngüsel sırasına uygun). Dizi uzunluğu bu adımın pozitif bir katı olmalıdır. Yazılan tüm patch'ler flag = 0 taşır (bağımsız patch); 1 / 2 / 3 devam flag'leri (bir önceki patch ile kenar paylaşımı) bu kolaylık overload'ında sunulmaz

 

Dönüş değeri: otomatik üretilmiş bir pattern adı (Sh1, Sh2, ...); geçerli sayfanın Resources/Pattern sözlüğüne kaydedilir. StrictVersionLock açıkken ve etkin Version PDF 1.3'ün altındayken boş string döndürür (aksi hâlde belge sürümü otomatik olarak 1.3'e yükseltilir)

 

Kod Örneği

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

 

Ayrıca bkz.

RegisterCoonsPatchMesh, RegisterFreeFormGouraudShading, RegisterLatticeFormGouraudShading, Version, PDF Filter Support