Class LinearGradient
Hierarchy
- BaseGradient
- LinearGradient
Index
Constructors
constructor
Creates a new linear gradient
Parameters
Optional x0: number
Optional y0: number
Optional x1: number
Optional y1: number
Returns LinearGradient
Accessors
color Stops
Color stops of the gradient
Returns GradientColorStop[]
x0
X axis coordinate of the starting point in the line
Returns number
x1
X axis coordinate of the ending point in the line
Returns number
y0
Y axis coordinate of the starting point in the line
Returns number
y1
Y axis coordinate of the ending point in the line
Returns number
Methods
add Color StopSearch playground for addColorStop
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
clear Color StopsSearch playground for clearColorStops
Removes all color stops from the gradient
Returns void
get Canvas GradientSearch playground for getCanvasGradient
If there are any changes or the context changed, regenerate the canvas gradient object. Else, reuse the existing gradient.
Parameters
context: ICanvasRenderingContext
Returns CanvasGradient
get Class NameSearch playground for getClassName
Class name of the gradient
Returns string
the class name of the gradient
parseSearch playground for parse
Parses a gradient from a serialization object
Parameters
serializationObject: any
the object to parse from
Returns void
remove Color StopSearch playground for removeColorStop
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
serializeSearch playground for serialize
Serializes this gradient
Parameters
serializationObject: any
the object to serialize to
Returns void
Gradient along a line that connects two coordinates. These coordinates are relative to the canvas' space, not to any control's space.
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createLinearGradient