> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# SharpDX.Direct2D1.LinearGradientBrush

Disclaimer: The **SharpDX SDK Reference** section was compiled from the official **SharpDX Documentation** and was NOT authored by NinjaTrader. The contents of this section are provided as-is and only cover a fraction of what is available from the SharpDX SDK. This page was intended only as a reference guide to help you get started with some of the 2D Graphics concepts used in the NinjaTrader.Custom assembly. Please refer to the official SharpDX Documentation for additional members not covered in this reference. For more seasoned graphic developers, the original MSDN **Direct2D1** and **DirectWrite** unmanaged API documentation can also be helpful for understanding the DirectX/Direct2D run-time environment. For NinjaScript development purposes, we document only essential members in the structure of this page.

## Definition

Paints an area with a linear gradient.

(See also [unmanaged API documentation](http://msdn.microsoft.com/en-us/library/dd371488.aspx))

Notes:

1. A **LinearGradientBrush** paints an area with a linear gradient along a line between the brush start point and end point. The gradient, defined by the brush [GradientStopCollection](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-lineargradientbrush/sharpdx-direct2d1-lineargradientbrush-gradientstopcollection), is extruded perpendicular to this line, and then transformed by a brush [transform](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-brush/sharpdx-direct2d1-brush-transform) (if specified).
2. The start point and end point are described in the brush space and are mapped to the render target when the brush is used. Note the starting and ending coordinates are absolute, not relative to the render target size. A value of (0, 0) maps to the upper-left corner of the render target, while a value of (1, 1) maps one pixel diagonally away from (0, 0). If there is a nonidentity [brush transform](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-brush/sharpdx-direct2d1-brush-transform) or [render target transform](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-rendertarget/sharpdx-direct2d1-rendertarget-transform), the brush [start point](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-lineargradientbrush/sharpdx-direct2d1-lineargradientbrush-startpoint) and [end point](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-lineargradientbrush/sharpdx-direct2d1-lineargradientbrush-endpoint) are also transformed.
3. It is possible to specify a gradient axis that does not completely fill the area that is being painted. When this occurs, the ExtendMode, specified by the [GradientStopCollection](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-lineargradientbrush/sharpdx-direct2d1-lineargradientbrush-gradientstopcollection), determines how the remaining area is painted.
4. The **LinearGradientBrush** can only be used with the [render target](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-rendertarget) that created it or with the compatible targets for that render target.
5. A **LinearGradientBrush** is a device-dependent resource: your application should create linear gradient brushes after it initializes the render target with which the brushes will be used, and recreate the brushes whenever the render target needs recreated. Please see the [MSDN Direct2D Resources Overview](https://msdn.microsoft.com/en-us/library/dd756757\(v=vs.85\).aspx) for more information.
6. For convenience, Direct2D provides the [RadialGradientBrushProperties](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-lineargradientbrush/sharpdx-direct2d1-lineargradientbrushproperties) function for creating a new **LinearGradientBrush**.

## Syntax

`class SolidColorBrush`

Tips:

1. For NinjaScript Development purposes, you can use the [NinjaTrader.Gui.DxExtensions.ToDxBrush()](/developer/desktop-sdk/references/common/charts/rendering/todxbrush) helper method to convert a **System.Windows.Media.LinearGradientBrush** to a **SharpDX.Direct2D1.LinearGradientBrush**.
2. General information on Direct2D brushes can be found on the [MSDN Direct2D Brushes Overview](https://msdn.microsoft.com/en-us/library/dd756651\(v=vs.85\).aspx).

## Constructors

| Constructor                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Description                                                                                                                    |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| new **LinearGradientBrush**([RenderTarget](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-rendertarget) renderTarget, [LinearGradientBrushProperties](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-lineargradientbrush/sharpdx-direct2d1-lineargradientbrushproperties) linearGradientBrushProperties, [GradientStopCollection](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-gradientstopcollection) gradientStopCollection)                                                                                                                                              | Creates a **LinearGradientBrush** that contains the specified gradient stops and has the specified transform and base opacity. |
| new **LinearGradientBrush**([RenderTarget](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-rendertarget) renderTarget, [LinearGradientBrushProperties](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-lineargradientbrush/sharpdx-direct2d1-lineargradientbrushproperties) linearGradientBrushProperties, Nullable\<[BrushProperties](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-brushproperties)> brushProperties, [GradientStopCollection](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-gradientstopcollection) gradientStopCollection) | Creates a **LinearGradientBrush** that contains the specified gradient stops and has the specified transform and base opacity. |

## Methods and Properties

| Method/Property                                                                                                                                                                          | Description                                                                                                                                                                                                     |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Dispose()](/developer/desktop-sdk/references/sharpdx/sharpdx-disposebase/sharpdx-disposebase-dispose)                                                                                   | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from [SharpDX.DisposeBase](/developer/desktop-sdk/references/sharpdx/sharpdx-disposebase)). |
| [EndPoint](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-lineargradientbrush/sharpdx-direct2d1-lineargradientbrush-endpoint)                             | Retrieves or sets the ending coordinates of the linear gradient.                                                                                                                                                |
| [GradientStopCollection](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-lineargradientbrush/sharpdx-direct2d1-lineargradientbrush-gradientstopcollection) | Retrieves the GradientStopCollection associated with this linear gradient brush.                                                                                                                                |
| [IsDisposed](/developer/desktop-sdk/references/sharpdx/sharpdx-disposebase/sharpdx-disposebase-isdisposed)                                                                               | Gets a value indicating whether this instance is disposed. (Inherited from [SharpDX.DisposeBase](/developer/desktop-sdk/references/sharpdx/sharpdx-disposebase)).                                               |
| [Opacity](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-brush/sharpdx-direct2d1-brush-opacity)                                                           | Gets or sets the degree of opacity of this brush. (Inherited from [Brush](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-brush)).                                                |
| [StartPoint](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-lineargradientbrush/sharpdx-direct2d1-lineargradientbrush-startpoint)                         | Retrieves or sets the starting coordinates of the linear gradient.                                                                                                                                              |
| [Transform](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-brush/sharpdx-direct2d1-brush-transform)                                                       | Gets or sets the transform applied to this brush. (Inherited from [Brush](/developer/desktop-sdk/references/sharpdx/sharpdx-direct2d1/sharpdx-direct2d1-brush)).                                                |