LinearGradientBrush.GradientStops()

From Xojo Documentation

Property (As Pair )
aLinearGradientBrush.GradientStops() = newPairValue
or
PairValue = aLinearGradientBrush.GradientStops()

Supported for all project types and targets.

An array of values indicating the locations where the gradient changes color.

Notes

Each element of the array is a Pair where the left value is a position and the right, a Color. The position is the percentage of the area to be drawn with the Color passed.

Example Code

This example (in the Paint event of a Canvas control) draws an oval with a gradient. The GradientStops property is used to add gradients at 0%, 40%, 70% and 100%. In this example, red will be used from 0% to 40% of the drawing area:

Var linearBrush As New LinearGradientBrush
linearBrush.StartPoint = New Point(0, 0)
linearBrush.EndPoint = New Point(g.Width, g.Height)
linearBrush.GradientStops.Add(New Pair(0.0, Color.Red))
linearBrush.GradientStops.Add(New Pair(0.4, Color.Yellow))
linearBrush.GradientStops.Add(New Pair(0.7, Color.Magenta))
linearBrush.GradientStops.Add(New Pair(1.0, Color.Blue))

g.Brush = linearBrush
g.FillOval(0, 0, g.Width, g.Height)