欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript+html5 canvas繪制漸變區(qū)域完整實(shí)例

 更新時(shí)間:2016年01月26日 11:53:34   作者:m1870164  
這篇文章主要介紹了JavaScript+html5 canvas繪制漸變區(qū)域的方法,結(jié)合完整實(shí)例形式分析了canvas顏色調(diào)用與圖形繪制的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了JavaScript+html5 canvas繪制漸變區(qū)域的方法。分享給大家供大家參考,具體如下:

運(yùn)行效果截圖如下:

具體代碼如下:

<!DOCTYPE html>
<html>
 <head>
  <title>demo</title>
  <style type="text/css">
   #canvas {
    border:3px solid gray;
   }
  </style>
 </head>
 <body>
  <canvas id="canvas" width="500px" height="500px"></canvas>
 </body>
 <script type="text/javascript">
  var canvas = document.getElementById("canvas");
  var ctx = canvas.getContext("2d");
  ctx.beginPath();
  ctx.rect(0, 0, 200, 200);
  ctx.closePath();
  var gradient = ctx.createLinearGradient(0, 0, 200, 200);
  gradient.addColorStop(0, "gray");
  gradient.addColorStop(0.5, "red");
  gradient.addColorStop(1, "blue");
  ctx.fillStyle = gradient;
  ctx.fill();
 </script>
</html>

更多關(guān)于js特效相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《jQuery動(dòng)畫(huà)與特效用法總結(jié)》及《jQuery常見(jiàn)經(jīng)典特效匯總

希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論