Class

# LinearGradientBrush

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Creates an image consisting of a progressive transition between two or more colors along a straight line.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                  | Type                         | Read-Only | Shared |
|-------------------------------------------------------|------------------------------|-----------|--------|
| `EndPoint<lineargradientbrush.endpoint>`              | `Point</api/graphics/point>` |           |        |
| `GradientStops\()<lineargradientbrush.gradientstops>` | `Pair</api/language/pair>`   |           |        |
| `StartPoint<lineargradientbrush.startpoint>`          | `Point</api/graphics/point>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                           | Parameters                                                                                                                                                       | Returns | Shared |
|------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|--------|
| `Constructor<lineargradientbrush.constructor>` | startPoint As `Point</api/graphics/point>`, endPoint As `Point</api/graphics/point>`, stops() As `Pair</api/language/pair>`                                      |         |        |
|                                                | startPoint As `Point</api/graphics/point>`, endPoint As `Point</api/graphics/point>`, `ParamArray</api/language/paramarray>` stops As `Pair</api/language/pair>` |         |        |

## Property descriptions

<div id="lineargradientbrush.endpoint">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

LinearGradientBrush.EndPoint

**EndPoint** As `Point</api/graphics/point>`

> The location within the `Graphics</api/graphics/graphics>` object where the gradient will end.

<div id="lineargradientbrush.gradientstops">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

LinearGradientBrush.GradientStops

**GradientStops**() As `Pair</api/language/pair>`

> An array of values indicating the locations where the gradient changes color.
>
> Each element of the array is a `Pair</api/language/pair>` where the left value is a position and the right, a `Color</api/data_types/color>`. The position is the percentage of the area to be drawn with the `Color</api/data_types/color>` passed.
>
> This example (in the `Paint<desktopcanvas.paint>` event of a `Canvas</api/user_interface/desktop/desktopcanvas>` control) draws an oval with a gradient. The GradientStops property is used to add gradients at 0%, 40%, 70% and 100%. In this example, `red<color.red>` will be used from 0% to 40% of the drawing area:
>
> ``` xojo
> 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.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)
> ```

<div id="lineargradientbrush.startpoint">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

LinearGradientBrush.StartPoint

**StartPoint** As `Point</api/graphics/point>`

> Location within the `Graphics</api/graphics/graphics>` object where the gradient will start.

## Method descriptions

<div id="lineargradientbrush.constructor">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

LinearGradientBrush.Constructor

**Constructor**(startPoint As `Point</api/graphics/point>`, endPoint As `Point</api/graphics/point>`, stops() As `Pair</api/language/pair>`)

**Constructor**(startPoint As `Point</api/graphics/point>`, endPoint As `Point</api/graphics/point>`, `ParamArray</api/language/paramarray>` stops As `Pair</api/language/pair>`)

> Creates the <span class="title-ref">LinearGradientBrush</span> from the parameters passed.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> The new <span class="title-ref">LinearGradientBrush</span> created will be passed copies of the `Points</api/graphics/point>` and `Pairs</api/language/pair>` parameters.
>
> </div>

## Notes

## Sample code

This code in the `Paint<desktopcanvas.paint>` event of a `Canvas</api/user_interface/desktop/desktopcanvas>` draws an oval filled with a linear gradient:

``` xojo
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

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`GraphicsBrush</api/graphics/graphicsbrush>` parent class; `Graphics.Brush<graphics.brush>` property, `PictureBrush</api/graphics/picturebrush>`, `ShadowBrush</api/graphics/shadowbrush>`, and `RadialGradientBrush</api/graphics/radialgradientbrush>` classes.

</div>
