Class RadialGradient
Hierarchy (View Summary)
- BaseGradient
- RadialGradient
Constructors
constructor
-
new RadialGradient(
x0?: number,
y0?: number,
r0?: number,
x1?: number,
y1?: number,
r1?: number,
): RadialGradientCreates a new radial gradient
Parameters
Optionalx0: numberx coordinate of the first circle's center
Optionaly0: numbery coordinate of the first circle's center
Optionalr0: numberradius of the first circle
Optionalx1: numberx coordinate of the second circle's center
Optionaly1: numbery coordinate of the second circle's center
Optionalr1: numberradius of the second circle
Returns RadialGradient
Accessors
color Stops
-
Color stops of the gradient
Returns GradientColorStop[]
r0
-
get r0(): number
radius of the first circle
Returns number
r1
-
get r1(): number
radius of the second circle
Returns number
x0
-
get x0(): number
x coordinate of the first circle's center
Returns number
x1
-
get x1(): number
x coordinate of the second circle's center
Returns number
y0
-
get y0(): number
y coordinate of the first circle's center
Returns number
y1
-
get y1(): number
y coordinate of the second circle's center
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 formed from two circles with their own centers and radius. The coordinates of the circles centers are relative to the canvas' space, not to any control's space.
See
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createRadialGradient