Class LinearGradient
Hierarchy (View Summary)
- BaseGradient
- LinearGradient
Constructors
constructor
-
Creates a new linear gradient
Parameters
Optionalx0: numberOptionaly0: numberOptionalx1: numberOptionaly1: number
Returns LinearGradient
Accessors
color Stops
-
Color stops of the gradient
Returns GradientColorStop[]
x0
-
get x0(): number
X axis coordinate of the starting point in the line
Returns number
x1
-
get x1(): number
X axis coordinate of the ending point in the line
Returns number
y0
-
get y0(): number
Y axis coordinate of the starting point in the line
Returns number
y1
-
get y1(): number
Y axis coordinate of the ending point in the line
Returns number
Methods
add Color Stop
-
Adds a new color stop to the gradient.
Parameters
- offset: number
the offset of the stop on the gradient. Should be between 0 and 1
- color: string
the color of the stop
Returns void
- offset: number
clear Color Stops
-
Removes all color stops from the gradient
Returns void
get Canvas Gradient
-
If there are any changes or the context changed, regenerate the canvas gradient object. Else, reuse the existing gradient.
Parameters
- context: ICanvasRenderingContext
the context to create the gradient from
Returns CanvasGradient
the canvas gradient
- context: ICanvasRenderingContext
get Class Name
-
Class name of the gradient
Returns string
the class name of the gradient
parse
-
Parses a gradient from a serialization object
Parameters
- serializationObject: any
the object to parse from
Returns void
- serializationObject: any
remove Color Stop
-
Removes an existing color stop with the specified offset from the gradient
Parameters
- offset: number
the offset of the stop to be removed
Returns void
- offset: number
serialize
-
Serializes this gradient
Parameters
- serializationObject: any
the object to serialize to
Returns void
- serializationObject: any
Gradient along a line that connects two coordinates. These coordinates are relative to the canvas' space, not to any control's space.
See
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createLinearGradient