-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
34 lines (21 loc) · 1.14 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---
title: CanvasGradient
slug: Web/API/CanvasGradient
page-type: web-api-interface
browser-compat: api.CanvasGradient
---
{{APIRef("Canvas API")}}{{AvailableInWorkers}}
The **`CanvasGradient`** interface represents an [opaque object](https://en.wikipedia.org/wiki/Opaque_data_type) describing a gradient. It is returned by the methods {{domxref("CanvasRenderingContext2D.createLinearGradient()")}}, {{domxref("CanvasRenderingContext2D.createConicGradient()")}} or {{domxref("CanvasRenderingContext2D.createRadialGradient()")}}.
It can be used as a {{domxref("CanvasRenderingContext2D.fillStyle", "fillStyle")}} or {{domxref("CanvasRenderingContext2D.strokeStyle", "strokeStyle")}}.
## Instance properties
_As an opaque object, there is no exposed property._
## Instance methods
- {{domxref("CanvasGradient.addColorStop()")}}
- : Adds a new stop, defined by an `offset` and a `color`, to the gradient.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- Creator methods in {{domxref("CanvasRenderingContext2D")}}.
- The {{HTMLElement("canvas")}} element and its associated interface, {{domxref("HTMLCanvasElement")}}.