CanvasGradient

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("Canvas API")}}{{AvailableInWorkers}}

The **CanvasGradient** interface represents an opaque object 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")}}.