AggPas - Anti-Grain Geomertry for Object Pascal

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

Description

Radial fill 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 fill gradient is consequently used to fill interior 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);

  // Gradient colors
  // from DeepSkyBlue #00BFFF - Red #FF0000
  c1.Construct($00, $BF, $FF);
  c2.Construct($FF, $00, $00);

  // Gradient proceeds from center point
  // (ClientWidth / 2:ClientHeight / 2)
  // with extent of (ClientWidth - 30) / 2
  VG.FillRadialGradient(ClientWidth / 2, ClientHeight / 2, 
   (ClientWidth - 30) / 2, c1, c2, 1.0);

  // Gradient appears as a filling of objects being drawn
  VG.Ellipse(ClientWidth / 2, ClientHeight / 2,
   (ClientWidth - 30) / 2, (ClientWidth - 30) / 2);

  end;

Screenshot: FillRadialGradient example