THotPDF.RegisterMultiStopRadialGradient Method
Registers a reusable native PDF radial shading that interpolates two or more color stops between a start circle and an end circle
Declaration
function RegisterMultiStopRadialGradient(X0, Y0, R0, X1, Y1, R1: Single; const StopPositions: array of Single; const StopColors: array of Single; ComponentsPerStop: Integer): AnsiString;
Unit
HPDFDoc
Parameters
| Name | Purpose |
|---|---|
X0, Y0, R0 | Center and non-negative radius of the start circle at offset zero |
X1, Y1, R1 | Center and non-negative radius of the end circle at offset one; this radius may be smaller than R0 |
StopPositions | Two or more nondecreasing finite offsets in the inclusive range zero to one; equal neighbors form a hard color stop |
StopColors | Flat-packed finite color components in the inclusive range zero to one |
ComponentsPerStop | 1 selects DeviceGray, 3 selects DeviceRGB, and 4 selects DeviceCMYK |
Return value
Returns the generated Pattern resource name for THPDFPage.SetFillPattern or THPDFPage.SetStrokePattern
Behavior
- Builds one PDF Function Type 3 stitching function from bounded Function Type 2 segments
- Emits a Shading Type 3 dictionary and wraps it in a reusable Pattern Type 2 resource
- Uses constant first and last colors before and after the authored stop interval, including omitted zero and one endpoints
- Builds only positive-width function intervals, preserving both sides of repeated offsets without duplicate stitching boundaries
- Expands endpoint geometry where needed to retain outside pad colors; expansion stops at the circle family's zero-radius tip and uses the color on the valid side there
- Keeps the original circle order for growing and shrinking radii and retains the original stop parameter scale
- Rejects non-finite coordinates, negative radii, malformed color arrays, decreasing offsets, and offsets or color components outside their valid ranges
- Requires PDF 1.3 and follows the document version-lock policy
Example
PatternName := Document.RegisterMultiStopRadialGradient(
300, 400, 0, 300, 400, 250,
[0.0, 0.5, 1.0],
[1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0], 3);
Document.CurrentPage.SetFillPattern(PatternName);