|
PDF 1.3+ lattice biçimli Gouraud shaded üçgen mesh shading'i (ISO 32000-1 8.7.4.5.5, /ShadingType 5) bildirir ve sayfanın Resources/Pattern sözlüğünde satır içi bir Pattern Type 2 girdisiyle sarar. Renderer, bitişik her satır çiftini otomatik olarak bir üçgen şeridine böler; çağıran yalnızca vertex ızgarasını verir. Kaynak veri zaten düzenli bir örnekleme ızgarasında olduğunda (arazi, FEA sonuçları, bilimsel heatmap'ler) kullanışlıdır. Üçgenleme düzensizse ve üçgen başına flag gerekiyorsa bunun yerine RegisterFreeFormGouraudShading kullanın
Delphi sözdizimi:
function RegisterLatticeFormGouraudShading(XMin, YMin, XMax, YMax: Single; NumComponents: Integer; VerticesPerRow: Integer; const Vertices: array of Extended): AnsiString;
C++ sözdizimi:
AnsiString RegisterLatticeFormGouraudShading(float XMin, float YMin, float XMax, float YMax, int NumComponents, int VerticesPerRow, const Extended* Vertices, int VertexElementCount);
Açıklama
Shading, /ShadingType 5, /BitsPerCoordinate 16, /BitsPerComponent 8 ve /VerticesPerRow N ile indirect stream olarak yayılır. Type 4 aksine per-vertex flag byte yoktur ve /BitsPerFlag shading dictionary içinde bulunmaz; her vertex 4 + NumComponents byte kaplar (2 big-endian X + 2 big-endian Y + N renk componenti). /Decode arrayi 16-bit koordinatları sağlanan [XMin, XMax] x [YMin, YMax] user-space dikdörtgenine ve her renk componentini [0, 1] aralığına geri map eder.
Vertices row-major sıralanır: ilk VerticesPerRow vertex row 0 oluşturur, sonraki VerticesPerRow row 1 oluşturur ve böyle devam eder. Renderer her adjacent row çiftini (row i ve row i+1) triangle strip haline bağlar - flag yok, explicit triangle list yok. Vertices içinde geçirdiğiniz Extended değerlerinin sayısı (2 + NumComponents) * VerticesPerRow katı olmalı ve ortaya çıkan row count en az 2 olmalıdır.
XMin, YMin, XMax, YMax - lattice değerini sınırlayan user-space dikdörtgeni. Bu dört değer /Decode içindeki ilk dört entry 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 - vertex 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.
VerticesPerRow - lattice row başına vertex sayısı N, N >= 2. Dictionary entry /VerticesPerRow bu değeri aynen alır. Row sayısı M array length üzerinden VertexCount / VerticesPerRow olarak çıkarılır ve en az 2 olmalıdır.
Vertices - vertex başına (X, Y, c1...cN) sırasındaki Extended değerlerinden oluşan flat array, row-major tekrarlanır (önce row 0, sonra row 1, ...). Koordinatlar [XMin, XMax] x [YMin, YMax] içine clamp edilir ve 16-bit integerlara quantise edilir; renk componentleri [0, 1] içine clamp edilir ve 8-bit integerlara quantise edilir.
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
// 3x3 lattice over a 200x200 quad. The renderer auto-triangulates
// adjacent rows into a triangle strip, giving 4 cells x 2 triangles
// = 8 triangles. Colour layout (visual):
//
// row 0 (top, Y=YMax): red yellow green
// row 1 (mid): magenta gray cyan
// row 2 (bot, Y=YMin): blue purple orange
var
Doc: THotPDF;
PatName: AnsiString;
Verts: array[0..44] of Extended; // 9 vertices x 5 floats each
H, XMin, YMin, XMax, YMax, XMid, YMid: 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;
XMid := (XMin + XMax) / 2;
YMid := (YMin + YMax) / 2;
// row 0 (Y=YMax): red - yellow - green
Verts[ 0] := XMin; Verts[ 1] := YMax; Verts[ 2] := 1.0; Verts[ 3] := 0.0; Verts[ 4] := 0.0;
Verts[ 5] := XMid; Verts[ 6] := YMax; Verts[ 7] := 1.0; Verts[ 8] := 1.0; Verts[ 9] := 0.0;
Verts[10] := XMax; Verts[11] := YMax; Verts[12] := 0.0; Verts[13] := 1.0; Verts[14] := 0.0;
// row 1 (Y mid): magenta - gray - cyan
Verts[15] := XMin; Verts[16] := YMid; Verts[17] := 1.0; Verts[18] := 0.0; Verts[19] := 1.0;
Verts[20] := XMid; Verts[21] := YMid; Verts[22] := 0.5; Verts[23] := 0.5; Verts[24] := 0.5;
Verts[25] := XMax; Verts[26] := YMid; Verts[27] := 0.0; Verts[28] := 1.0; Verts[29] := 1.0;
// row 2 (Y=YMin): blue - purple - orange
Verts[30] := XMin; Verts[31] := YMin; Verts[32] := 0.0; Verts[33] := 0.0; Verts[34] := 1.0;
Verts[35] := XMid; Verts[36] := YMin; Verts[37] := 0.5; Verts[38] := 0.0; Verts[39] := 0.5;
Verts[40] := XMax; Verts[41] := YMin; Verts[42] := 1.0; Verts[43] := 0.5; Verts[44] := 0.0;
PatName := Doc.RegisterLatticeFormGouraudShading(
XMin, YMin, XMax, YMax, 3, 3, Verts);
Doc.CurrentPage.SetFillPattern(PatName);
Doc.CurrentPage.Rectangle(0, 0, 200, 200);
Doc.CurrentPage.Fill;
Doc.EndDoc;
finally
Doc.Free;
end;
end;
Ayrıca bkz.
RegisterFreeFormGouraudShading, RegisterDeviceN, RegisterSeparation, RegisterLabColorSpace, Version, PDF Filter Support
|