LinearGradient
Inherits from: Paint
Overview
The
LinearGradient class fills a shape with a linear color gradient pattern. The user may specify two or more gradient colors, and this Paint will provide an interpolation between each color.
The application provides an array of
Stops specifying how to distribute the colors along the gradient. The
Stop#offset variable must be the range 0.0 to 1.0 and act like keyframes along the gradient. They mark where the gradient should be exactly a particular color.
If the proportional variable is set to true (the default) then the start and end points of the gradient should be specified relative to the unit square (0.0->1.0) and will be stretched across the shape. If proportional variable is set to false, then the start and end points should be specified as absolute pixel values and the gradient will not be stretched at all.
The two filled rectangles in the example below will render the same. The one on the left uses proportional coordinates (the default) to specify the gradient's end points. The one on the right uses absolute coordinates. Both of them fill the specified rectangle with a horizontal gradient that varies from black to red
Profile: common
Variable Summary
| name | type | Default Value | description |
|---|---|---|---|
| startX | Number | 0.0 |
Defines the X coordinate of the gradient axis start point. If proportional is true (the default), this value specifies a point on a unit square that will be scaled to match the size of the the shape that the gradient fills. |
| startY | Number | 0.0 |
Defines the Y coordinate of the gradient axis start point. If proportional is true (the default), this value specifies a point on a unit square that will be scaled to match the size of the the shape that the gradient fills. |
| endX | Number | 1.0 |
Defines the X coordinate of the gradient axis end point. If proportional is true (the default), this value specifies a point on a unit square that will be scaled to match the size of the the shape that the gradient fills. |
| endY | Number | 1.0 |
Defines the Y coordinate of the gradient axis end point. If proportional is true (the default), this value specifies a point on a unit square that will be scaled to match the size of the the shape that the gradient fills. |
| proportional | Boolean | true |
Indicates whether start and end values are proportional or absolute. If this flag is true, start and end values are defined in a [0..1] space and will be scaled to match the size of the shape that the gradient fills. If this flag is false, then start and end values are absolute coordinates. |
| cycleMethod | CycleMethod | CycleMethod.NO_CYCLE |
Defines which of the follwing cycle method is applied to the
|
| stops | Stop | [] |
A sequence of 2 or more
Each stop in the sequence must have an offset that is greater than the previous stop in the sequence. |
