THotPDF.RegisterCoonsPatchMesh Method

 

THotPDF.RegisterCoonsPatchMesh

THotPDF

 

Vrh

Razglasi Coonsov senčen mrežni popravek PDF 1.3+ (ISO 32000-1 8.7.4.5.6, /ShadingType 6) in ga ovije v vnos inline Pattern Type 2 v slovar Resources/Pattern na strani. Vsak popravek je omejen s štirimi kubičnimi Bezierjevimi krivuljami in nosi eno barvo na vogal; izrisovalnik prilega Coonsovo površino med štiri robove in s tem ustvari poljuben ukrivljen štirikotnik z barvo. Uporabite ga, kadar bi ravni trikotni mrežni vzorci (RegisterFreeFormGouraudShading, RegisterLatticeFormGouraudShading) za približek ukrivljenih mej potrebovali preveč trikotnikov - folijski in kovinski prelivi na upognjenih poteh, gradientne mreže iz SVG in vsak quad z ukrivljenimi robovi

 

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

 

Description

Senčenje je izpisano kot posredni tok z /ShadingType 6, /BitsPerCoordinate 16, /BitsPerComponent 8 in /BitsPerFlag 8. Vsak popravek je zapakiran kot 1 bajt zastavice (vedno 0 za neodvisne popravke), ki mu sledi 12 kontrolnih točk (vsaka 4 bajti: 2 big-endian X + 2 big-endian Y) in 4 barve vogalov (vsaka NumComponents bajtov), skupaj 1 + 48 + 4 * NumComponents bajtov na popravek. Polje /Decode preslika 16-bitne koordinate nazaj v podani pravokotnik uporabniškega prostora [XMin, XMax] x [YMin, YMax] in vsak barvni komponent nazaj v [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 - pravokotnik v uporabniškem prostoru, ki omejuje kodirane koordinate. Te štiri vrednosti postanejo prvi štirje vnosi /Decode. Kontrolne točke zunaj tega pravokotnika se pri kodiranju pripnejo. Postavite jih v iste uporabniške koordinate, v katere boste risali - za HotPDFov zaslonsko-koordinatni Rectangle pri (X, Y, W, H) je ustrezen pravokotnik v PDF uporabniškem prostoru (X, PageHeight - Y - H) do (X + W, PageHeight - Y)

NumComponents - število barvnih komponent na vogal. Vrednost 1 uporabite za DeviceGray, 3 za DeviceRGB ali 4 za DeviceCMYK. Vsaka druga vrednost sproži izjemo

Patches - ravno polje vrednosti Extended. Vsak popravek prispeva 24 + 4 * NumComponents vrednosti: 24 floatov za 12 kontrolnih točk (X, Y, X, Y, ..., 12 parov v zaporedju c1..c12 v smeri urinega kazalca) ter 4 * NumComponents floatov za barve vogalov (vogal 1 / 2 / 3 / 4 = c1 / c4 / c7 / c10 v krožnem vrstnem redu). Dolžina polja mora biti pozitiven večkratnik te velikosti. Vsi izpisani popravki nosijo flag = 0 (neodvisni popravek); nadaljevalne zastavice 1 / 2 / 3 (deljenje roba s prejšnjim popravkom) niso izpostavljene v tej priročni preobremenitvi

 

Povratna vrednost: samodejno generirano ime vzorca (Sh1, Sh2, ...) registrirano v slovarju Resources/Pattern trenutne strani. Vrne prazen niz, kadar je StrictVersionLock vklopljen in je aktivna Version pod PDF 1.3 (sicer se različica dokumenta samodejno poviša na 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;

 

Glejte tudi

RegisterFreeFormGouraudShading, RegisterLatticeFormGouraudShading, RegisterDeviceN, Version, PDF Filter Support