Class

RadialGradientBrush


Description

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

Methods

Name

Parameters

Returns

Shared

Constructor

startPoint As Point, endPoint As Point, startRadius As Double, endRadius As Double, stops() As Pair

startPoint As Point, endPoint As Point, startRadius As Double, endRadius As Double, ParamArray stops As Pair

Property descriptions


RadialGradientBrush.EndPoint

EndPoint As Point

The distance from the StartPoint to the point at which the gradient will end.


RadialGradientBrush.EndRadius

EndRadius As Double

The position within the Graphics object where the gradient will end.

Warning

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.

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.


RadialGradientBrush.GradientStops

GradientStops() As Pair

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

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.

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%, 50%, and 80%. In this example, red will be used from 0% to 50% of the drawing area:

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)

RadialGradientBrush.StartPoint

StartPoint As Point

The position within the Graphics object where the gradient will begin.


RadialGradientBrush.StartRadius

StartRadius As Double

The distance from the StartPoint to the point at which the gradient will start.

Warning

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.

Method descriptions


RadialGradientBrush.Constructor

Constructor(startPoint As Point, endPoint As Point, startRadius As Double, endRadius As Double, stops() As Pair)

Constructor(startPoint As Point, endPoint As Point, startRadius As Double, endRadius As Double, ParamArray stops As Pair)

Creates the RadialGradientBrush from the parameters passed.

Note

The new RadialGradientBrush created will be passed copies of the Points and Pairs parameters.

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.

Warning

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.

Note

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

All project types on all supported operating systems.

See also

GraphicsBrush parent class; Graphics.Brush property, LinearGradientBrush, PictureBrush, and ShadowBrush classes.