AggPas - Anti-Grain Geomertry for Object Pascal

TAgg2D.LineRadialGradient(x, y, r, c1, c2, profile)

Description

Radial line gradient produces equally proportioned circles of colors increasing from the origin to the outer bound.

Gradient's origin (center point) is defined by the x:y couple and the extent of the gradient is defined with radius r.

Radial line gradient is consequently used to fill strokes of objects being drawn. If there is a need to get the filling beyond gradient radius boundary, the c2 color is used as a solid color fill.

Parameters

x: double

X coordinate of gradient center point [in subpixels].

y: double

Y coordinate of gradient center point [in subpixels].

r: double

Radius of gradient outer bound circle [in subpixels].

c1: TAggColor [*]

First color of the gradient ramp used at center point
[data sructure (r, g, b, a)].

c2: TAggColor [*]

Last color of the gradient ramp used at gradient circle bound
[data sructure (r, g, b, a)].

profile: double = 1.0

Defines how to distribute the color transitions beginning from the halfway between center point and gradient circle outer bound. A value of 1 means to distribute colors proportionally on the whole radius. 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 gradient circle outer bound).

Example

if VG.Attach(Image1.Picture.Bitmap) then begin
  VG.ClearAll(255, 255, 255);

  // Turn off fill & set bold line
  VG.NoFill;
  VG.LineWidth(15);

  // Gradient colors from Red to Blue
  c1.Construct($FF, $00, $00);
  c2.Construct($00, $00, $FF);

  // Gradient proceeds from center point
  // (ClientWidth / 2:ClientHeight / 2)
  // with extent of (ClientWidth + 70) / 2
  // Concentration profile of 0.2 helps
  // to place gradient on the stroke of circle
  VG.LineRadialGradient(ClientWidth / 2, ClientHeight / 2,
   (ClientWidth + 70) / 2, c1, c2, 0.2);

  // Circle  
  VG.Ellipse(ClientWidth / 2, ClientHeight / 2,
   (ClientWidth - 80) / 2, (ClientWidth - 80) / 2);

end;

Screenshot: example