LinearGradientBrush

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 consisting of a progressive transition between two or more colors along a straight line.

Properties
EndPoint GradientStops() StartPoint

Notes

Sample Code

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

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, 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)

Compatibility

Desktop and iOS project types on all supported operating systems.

See Also

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