Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (28 sloc) 968 Bytes
<!doctype html>
<meta charset="utf-8">
<title>Gradient Fill 1</title>
<link rel="stylesheet" href="../include/style.css">
Example from <a href=""><em>Foundation HTML5 Animation with JavaScript</em></a>
<canvas id="canvas" width="400" height="400"></canvas>
window.onload = function () {
var canvas = document.getElementById('canvas'),
context = canvas.getContext('2d'),
pt1 = {x: 0, y: 0}, //gradient start point
pt2 = {x: 100, y: 100}, //gradient end point
gradient = context.createLinearGradient(pt1.x, pt1.y, pt2.x, pt2.y);
//white to red
gradient.addColorStop(0, "#ffffff");
gradient.addColorStop(1, "#ff0000");
context.fillStyle = gradient;
context.fillRect(0, 0, 100, 100);