addColorStop method
Adds the specified colors and the position in a CanvasGradient object.
![]() ![]() |
Syntax
HRESULT retVal = object.addColorStop(offset, color);
Parameters
- offset [in]
-
Type: float
A floating point value between 0.0 and 1.0 that represents the position between the start and end points in a gradient.
- color [in]
-
Type: string
A CSS color string to display at the position that the offset parameter specifies.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Standards information
- HTML Canvas 2D Context, Section 5
Remarks
You can call the ICanvasGradient::addColorStop method multiple times to change a gradient. If you never call this method for CanvasGradient, the gradient is not visible. You need to create at least one color stop to have a visible gradient.
See also
- Reference
- ICanvasRenderingContext2D::createRadialGradient
- ICanvasRenderingContext2D::createLinearGradient
Build date: 11/12/2012

