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)
Notes:
- 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, is extruded perpendicular to this line, and then transformed by a brush transform (if specified).
- 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 or render target transform, the brush start point and end point are also transformed.
- 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, determines how the remaining area is painted.
- The LinearGradientBrush can only be used with the render target that created it or with the compatible targets for that render target.
- 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 for more information.
- For convenience, Direct2D provides the RadialGradientBrushProperties function for creating a new LinearGradientBrush.
Syntax
class SolidColorBrush
Tips:
- For NinjaScript Development purposes, you can use the NinjaTrader.Gui.DxExtensions.ToDxBrush() helper method to convert a System.Windows.Media.LinearGradientBrush to a SharpDX.Direct2D1.LinearGradientBrush.
- General information on Direct2D brushes can be found on the MSDN Direct2D Brushes Overview.

