CanvasGradient Class

A gradient of a canvas (https://html.spec.whatwg.org/multipage/canvas.html#canvasgradient): created by createLinearGradient(), createRadialGradient() and createConicGradient(), it is a fill or stroke style whose geometry is in the coordinates of the drawing operations that use it.

public sealed class CanvasGradient

Methods

NameDescription
AddColorStop(double, string)Adds a color stop (https://html.spec.whatwg.org/multipage/canvas.html#dom-canvasgradient-addcolorstop): a stop at the same offset as existing stops is placed after them.

AddColorStop(double, string)

CanvasGradient.cs

Adds a color stop (https://html.spec.whatwg.org/multipage/canvas.html#dom-canvasgradient-addcolorstop): a stop at the same offset as existing stops is placed after them.

public void AddColorStop(double offset, string color)

Parameters

offset double
The offset of the stop, from 0 to 1.
color string
A CSS color (currentcolor is opaque black).

Exceptions

DomException
An IndexSizeError when the offset is out of range, a SyntaxError when the color cannot be parsed.

See also