CanvasGradient class

An opaque canvas object representing a gradient.

Created by calling createLinearGradient or createRadialGradient on a CanvasRenderingContext2D object.

Example usage:

var canvas = new CanvasElement(width: 600, height: 600);
var ctx = canvas.context2D;
ctx.clearRect(0, 0, 600, 600);
ctx.save();
// Create radial gradient.
CanvasGradient gradient = ctx.createRadialGradient(0, 0, 0, 0, 0, 600);
gradient.addColorStop(0, '#000');
gradient.addColorStop(1, 'rgb(255, 255, 255)');
// Assign gradients to fill.
ctx.fillStyle = gradient;
// Draw a rectangle with a gradient fill.
ctx.fillRect(0, 0, 600, 600);
ctx.save();
document.body.children.add(canvas);

See also:

Inheritance
Annotations
  • @DocsEditable()
  • @DomName('CanvasGradient')

Static Properties

instanceRuntimeTypeType
@Deprecated("Internal Use Only"), read-only

Constructors

CanvasGradient.internal_()

Properties

hashCodeint
read-only, inherited
runtimeTypeType
read-only, inherited

A representation of the runtime type of the object.

Operators

operator ==(other) → bool
inherited

The equality operator.

Methods

addColorStop(num offset, String color) → void
@DocsEditable(), @DomName('CanvasGradient.addColorStop')

Adds a color stop to this gradient at the offset.

noSuchMethod(Invocation invocation) → dynamic
inherited

Invoked when a non-existent method or property is accessed.

toString() → String
inherited

Returns the result of the JavaScript objects toString method.

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-html/CanvasGradient-class.html