<!DOCTYPE html>
<html>
<body>
<canvas id ='output' width='200' height='200'></canvas>
<script>
var aCanvas = document.getElementById('output');
var ctx = aCanvas.getContext('2d');
var radialGrad = ctx.createRadialGradient(100, 100, 100, 100, 100, 0);
radialGrad.addColorStop(0, "#fff");
radialGrad.addColorStop(1, "#0f0");
ctx.fillStyle = radialGrad;
ctx.fillRect(0, 0, 200, 200);
var linearGrad = ctx.createLinearGradient(0, 0, 200, 200);
linearGrad.addColorStop(0, "#f00");
linearGrad.addColorStop(1, "#ff0");
ctx.strokeStyle = linearGrad;
ctx.lineWidth = "3";
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(200, 200);
ctx.stroke();
</script>
</body>
</html>