RadialGradientBrush

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from GraphicsBrush)


New in 2020r2

Creates an image which represents a gradient of colors radiating from an origin, the center of the gradient.

Properties
EndPoint GradientStops() StartRadius
EndRadius StartPoint

Notes

A radial gradient is made up of two concentric circles where the gradient begins at the inner circle (as defined by the StartPoint) and ends at the outer circle (as defined by the EndPoint).

To create the effect of the radial gradient progressing out from the center of the drawing, set the StartPoint and the EndPoint to the center of the drawing.

fa-exclamation-circle-32.png
Windows does not support the StartRadius. Therefore, if the StartPoint and EndPoint are not the same and the StartRadius is greater than 0, an InvalidArgumentException will occur.
fa-info-circle-32.png
On Windows, if the StartPoint and EndPoint are the same, the greater of the StartRadius/EndRadius is used.

If the EndRadius does not reach the edge of the drawing, the color of the last GradientStop will be use to fill the remaining area.

Sample Code

This example code in the Paint event of a Canvas draws an oval filled with a radial gradient:

Var radialBrush As New RadialGradientBrush
radialBrush.StartPoint = New Point(g.Width / 2, g.Height / 2)
radialBrush.EndPoint = radialBrush.StartPoint
radialBrush.GradientStops.Add(New Pair(0, Color.Red))
radialBrush.GradientStops.Add(New Pair(0.5, Color.Blue))
radialBrush.GradientStops.Add(New Pair(0.8, Color.Green))
radialBrush.StartRadius = 0
radialBrush.EndRadius = 500
g.Brush = radialBrush
g.FillOval(0, 0, g.Width, g.Height)

Compatibility

Desktop and iOS project types on all supported operating systems.

See Also

Graphics.Brush property, LinearGradientBrush, PictureBrush, and ShadowBrush classes.