CanvasGradient class - dart:html library (original) (raw)
An opaque canvas object representing a gradient.
Created by calling the methodsCanvasRenderingContext2D.createLinearGradient orCanvasRenderingContext2D.createRadialGradient on aCanvasRenderingContext2D 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:
- CanvasGradient from MDN.
- CanvasGradientfrom WHATWG.
- CanvasGradient from W3C.
Annotations
- @Native.new("CanvasGradient")
Properties
The hash code for this object.
no setterinherited
A representation of the runtime type of the object.
no setterinherited
Methods
addColorStop(num offset, String color)→ void
Adds a color stop to this gradient at the offset.
noSuchMethod(Invocation invocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
A string representation of this object.
inherited
Operators
operator ==(Object other)→ bool
The equality operator.
inherited