Advertisement
metalx1000

Radial Gradient Fill

Jun 29th, 2013
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.60 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.createRadialGradient(50, 50, 50, 50, 50, 250);
  14.  
  15.         grd.addColorStop(0, 'blue');
  16.         grd.addColorStop(0.2, 'red');
  17.         grd.addColorStop(0.8, 'blue');
  18.         grd.addColorStop(1, 'green');
  19.         context.fillStyle=grd;
  20.         context.fill();
  21.     </script>
  22.   </body>
  23. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement