HTLM5 颜色渐变效果

参考百度HTML5入门文档写的.

 

  <html>
 <canvas id= "myCanvas"></canvas>
 <script>
 var canvas = document.getElementById('myCanvas');
 var cxt = canvas.getContext('2d');
 var grd = cxt.createLinearGradient(0,0,250,250);
 grd.addColorStop(0, "FF0000");
 grd.addColorStop(1, "00FF00");
 cxt.fillStyle= grd;
 cxt.fillRect(0,0,250,250);
 </script>
 </html>

 


 

你可能感兴趣的:(html5,百度,文档)