TAgg2D.FillLinearGradient(x1, y1, x2, y2, c1, c2, profile)
Description
Linear fill gradient increases linearly along the line from starting to ending point and it is constant along perpendicular lines.
Starting point is defined by x1:y1 couple and ending point by x2:y2 couple.
Method internally computes an angle at which the line goes, and gradient gets sloped by that angle all the way.
Linear fill gradient is consequently used to fill interior of objects being drawn. If there is a need to get the filling before gradient's starting point, the c1 color is used as a solid color fill up to the starting point. Similarly space after the ending point is filled with solid c2 color fill.
Parameters
x1: double
X coordinate of gradient starting point [in subpixels].
y1: double
Y coordinate of gradient starting point [in subpixels].
x2: double
X coordinate of gradient ending point [in subpixels].
y2: double
Y coordinate of gradient ending point [in subpixels].
c1: TAggColor [*]
First color of the gradient ramp [data sructure (r, g, b, a)].
c2: TAggColor [*]
Last color of the gradient ramp [data sructure (r, g, b, a)].
profile: double = 1.0
Defines how to distribute the color transitions beginning from the halfway between starting and ending points of gradient color ramp. A value of 1 means to distribute colors proportionally on the whole length. Values less than 1 approximating to 0 define the ratio by which the transition is distributed more to the halfway position. Values more than 1 define expansion from halfway position (to a maximum of starting and ending points boundaries).
Example
if VG.Attach(Image1.Picture.Bitmap) then begin VG.ClearAll(255, 255, 255); // Gradient colors - from Red to Yellow c1.Construct(255, 0, 0); c2.Construct(255, 255, 0); // Gradient proceeds from Top Left corner (10:10) // to the Bottom Right corner // (ClientWidth - 10:ClientHeight - 10) VG.FillLinearGradient(10, 10, ClientWidth - 10, ClientHeight - 10, c1, c2, 0.9); // Gradient appears as a filling of objects // consequently being drawn VG.Rectangle(10, 10, ClientWidth - 10, ClientHeight - 10); end;
Remarks
One important note about gradients in TAgg2D is that gradients are defined per surface and not per rendering object. Gradient location and dimensions relates to origin of surface and coordinates transformations transform also gradients definition. So after setup of one gradient (for fill or stroke) a series of drawing shapes will render across the last defined gradient.



