DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> HTML基礎知識 >> HTML5詳解 >> HTML5畫漸變背景圖片並自動下載實現步驟
HTML5畫漸變背景圖片並自動下載實現步驟
編輯:HTML5詳解     
drawBgLine.Html

復制代碼代碼如下:
<!DOCTYPE Html> 
<head> 
<meta charset="UTF-8"/> 
<title>Html5畫漸變背景圖片,並自動下載</title> 
</head> 
<body> 
<center> 
<canvas id="c" width="1" height="200" ></canvas> 
</center> 
<script> 
//第一步:獲取canvas對象 
var c = document.getElementById("c"); 
//第二步:獲取canvas對象的上下文對象 
var context = c.getContext("2d"); 
/* 
* 這些是畫其他圖形代碼 
context.beginPath(); 
context.lineWidth=10; 
context.strokeStyle="red"; 
context.moveTo(50,50); 
context.lineTo(150,50); 
context.stroke(); 
context.closePath(); 
//context.strokeRect(220,50,50,50); 
context.fillStyle="blue"; 
context.fillRect(220,50,50,50); 
context.beginPath(); 
context.arc(150,150,50,0*Math.PI/180,-180*Math.PI/180,false); 
context.lineTo(150,150); 
context.closePath(); 
context.stroke(); 
context.lineWidth=1; 
context.font="50px 宋體"; 
context.fillText("briup",0,220); 
context.save(); 
context.translate(50,50); 
context.rotate(90*Math.PI/180); 
context.beginPath(); 
context.lineWidth=10; 
context.strokeStyle="red"; 
context.moveTo(0,0); 
context.lineTo(100,0); 
context.stroke(); 
context.closePath(); 
context.restore(); 
*/ 
var g = context.createLinearGradIEnt(0,0,0,200); 
g.addColorStop(0,"90BFFF"); 
g.addColorStop(1,"white"); 
context.fillStyle = g; 
context.fillRect(0,0,1,200); 
window.location = c.toDataURL("image/jpeg").replace("image/jpeg","image/octet-stream"); 
</script> 
</body> 
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved