🎜>
HTML5畫線、圓、長方形
">http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">>
<script><br />$(document).ready(function(){<br />var c=document.getElementById("drawbox");<br />var draw=c.getContext("2d"); //取得2d內容的引用,呼叫繪圖API
<p>//指定漸變區塊<br />var grd=draw.createLinearGradient(50,50,200,50); //座標,長寬<br />grd.addColorStop(0,"black"); //起點顏色<br />grd.addColorStop(1,"green"); //終點顏色
<p>draw.fillStyle=grd; //設為填滿樣式<br />draw.fillRect(50,50,200,50); //填入矩形內<br />})<br /></script>