Advertisement
metalx1000

Linear Gradient Fill

Jun 29th, 2013
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.61 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3.   <head>
  4.   </head>
  5.   <body>
  6.     <canvas id="myCanvas" width="600" height="300"></canvas>
  7.     <script>
  8.       var canvas = document.getElementById('myCanvas');
  9.       var context = canvas.getContext('2d');
  10.  
  11.         context.rect(0,0,canvas.width, canvas.height);
  12.  
  13.         var grd = context.createLinearGradient(0,0,canvas.width,canvas.height);
  14.  
  15.         grd.addColorStop(0, 'blue');
  16.         grd.addColorStop(0.3, 'red');
  17.         grd.addColorStop(0.6, 'green');
  18.         grd.addColorStop(1, 'yellow');
  19.         context.fillStyle=grd;
  20.         context.fill();
  21.     </script>
  22.   </body>
  23. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement