Implement gradient fill styles for canvas.

This commit is contained in:
Mátyás Mustoha 2015-02-06 13:55:32 +01:00
parent 34950418ea
commit d3199aef74
55 changed files with 290 additions and 228 deletions

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<body>
<style>
html, body {
margin: 0;
padding: 0;
}
canvas {
background-color: green;
}
</style>
<canvas id="c" width="200" height="200">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c = document.getElementById("c");
var ctx = c.getContext("2d");
var grd = ctx.createLinearGradient(10, 0, 190, 0);
grd.addColorStop(0, "red");
grd.addColorStop(1, "yellow");
ctx.fillStyle = grd;
ctx.fillRect(10, 10, 180, 180);
</script>
</body>
</html>