Skip to main content

GraphicsCache.GetGradientBrush(Rectangle, Color, Color, LinearGradientMode) Method

Returns a linear gradient brush with specified settings.

Namespace: DevExpress.Utils.Drawing

Assembly: DevExpress.Utils.v24.1.dll

NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core

Declaration

public Brush GetGradientBrush(
    Rectangle rect,
    Color startColor,
    Color endColor,
    LinearGradientMode mode
)

Parameters

Name Type Description
rect Rectangle

A System.Drawing.Rectangle structure that specifies the endpoints of the linear gradient. The starting point is the upper-left corner of the rectangle, and the endpoint is the upper-right corner of the rectangle.

startColor Color

A System.Drawing.Color object that represents the starting color for the gradient.

endColor Color

A System.Drawing.Color object that represents the ending color for the gradient.

mode LinearGradientMode

A System.Drawing.Drawing2D.LinearGradientMode enumeration value specifying the gradient orientation.

Returns

Type Description
Brush

A System.Drawing.Brush descendant representing the requested linear gradient brush (typically a System.Drawing.Drawing2D.LinearGradientBrush object).

Remarks

When the GetGradientBrush method is called, it checks whether the requested brush is already contained in an internal hash table of linear gradient brushes. If so, the found brush is returned. Otherwise a new brush with specified parameters is created and added to an internal hash table. The hash table is initially empty. The introduced technique allows you to provide quick access to recently used linear gradient brushes.

See Also