HTML5 Canvas標籤範例

隨著時代的進步,HTML的版本一直在進化,目前比較新的版本應該就是HTML5了,這次的HTML5針對許多標籤進行調整,當然也新增了一些標籤,主要的目的是希望可以將一些本來需要利用Flash才可以完成的互動頁面取而用HTML5來進行設計,這樣比較能減輕網頁的負載,但不管怎麼進步,其最重要的目的當然還是要網友能夠看到才行!

目前各家的瀏覽器對於HTML5的支援都不一,如果想要測試看看自己所使用的瀏覽器對HTML5的支援程度,可以到這個網址測試,馬老師針對目前的三款瀏覽器(IE9、Firefox6、Chrome13)來做了測試,IE9於HTML5中測試得到了以下的分數:

IE9於HTML5中測試分數

Firefox6於HTML5中測試得到了以下的分數:

Firefox6於HTML5中測試分數

Chrome13於HTML5中測試得到了以下的分數:

Chrome13於HTML5中測試分數

所以用以上的結果來看,目前是Google Chrome對於HTML5的支援最好,不過也只是拿了450分中的340而已,所以是否要全面改用HTML5來開發,還是應該要好好的斟酌一下,但是先了解HTML5能做到的功能,一定是沒問題的!以下就是馬老師針對HTML新增的畫布標籤製作的範例,不過因為瀏覽器支援的關係,必須使用Chrome觀賞才會是比較完整的功能喔!

範例觀賞頁面

範例影片:

PS:本範例的網頁所使用的圖檔為寬:800、高:600的圖檔,並將圖檔至於img的資料夾中

網頁程式碼:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Slide Show</title>
<script>

var context;
var x = 0;
var ind;
var offset;
var photos = new Array();

for(var i=1;i<=13;i++){
	var im = new Image();
	im.src = "img/p" + i + ".jpg";
	photos.push(im);
}

function slideshow(){
	context = document.getElementById('canvas').getContext('2d');
	setInterval(loop,10);
}

function loop(){
	x += (slider.value - x) * 0.1;
	ind = Math.floor(x/800);
	offset = x % 800;
	context.drawImage(photos[ind], offset, 0, 800-offset, 600, 0, 0, 800-offset, 600);
	context.drawImage(photos[ind+1], 0, 0, 800, 600, 800-offset, 0, 800, 600);
}

</script>
</head>
<body onLoad="slideshow()">

<canvas width="800" height="600" id="canvas"></canvas><br />
<input type="range" id="slider" style="width:800px;" min="0" max="9600" step="1" value="0">

</body>
</html>

You may also like...

4,243 Responses

  1. DouglasLep表示:

    cialis 20 mg price cialis online purchase of tadalafil in india

  2. twjnxjpv表示:

    buy provigil 100mg for sale buy generic provigil 100mg provigil 200mg usa

  3. guxsaefv表示:

    provigil 200mg sale provigil 200mg over the counter purchase provigil generic

  4. DouglasLep表示:

    viagra price for viagra sildenafil

  5. Stromsob表示:

    stromectol 3 mg tablets price stromectol price usa stromectol

  6. ulrmkbwd表示:

    order provigil 200mg pill order modafinil 100mg sale

  7. Stromsob表示:

    pharmacy without dr prescriptions discount prescription drugs online meds online without doctor prescription

  8. Stromsob表示:

    order prescriptions online without doctor canadian pharmacies not requiring prescription prescription drugs without doctor approval

  9. Stromsob表示:

    pharmacy without dr prescriptions meds online without doctor prescription top rated canadian pharmacies online

  10. Stromsob表示:

    compare ed drugs erectile dysfunction drugs best pill for ed

  11. GregoryHoaro表示:

    mens ed pills ed pills otc erectile dysfunction drugs

  12. GregoryHoaro表示:

    propecia uk propecia 1mg generic buy propecia no prescription

  13. GregoryHoaro表示:

    non prescription ed pills erectile dysfunction drugs best over the counter ed pills

  14. GregoryHoaro表示:

    cure ed best medication for ed ed meds

  15. GregoryHoaro表示:

    buy propecia online cheap generic propecia uk mail order propecia

  16. GregoryHoaro表示:

    ivermectin paste for pigs edenbridge pharmaceuticals ivermectin ivermectin for humans for sale

  17. GregoryHoaro表示:

    does ivermectin kill liver flukes ivermectin dosage for covid ivermectin tablet for sale

  18. Jamesval表示:

    prednisone 10mg tablet cost prednisone for sale prednisone pharmacy

  19. Jamesval表示:

    prednisone over the counter uk 20mg prednisone drug prices prednisone

  20. Jamesval表示:

    best price for generic viagra on the internet ed medications ed trial pack

  21. Jamesval表示:

    how long after taking ivermectin can i drink alcohol will ivermectin kill fleas liquid ivermectin for cats

  22. Jamesval表示:

    buy prednisone canadian pharmacy prednisone for sale online prednisone 60 mg price

  23. Jamesval表示:

    what is stromectol used for where can i get ivermectin for humans ivermectin 0.5% lotion

  24. Jamesval表示:

    cost of prednisone in canada prednisone for sale prednisone in india

  25. I was suggested this blog by my cousin. I’m not sure whether this post is written by him as no one else know such detailed about my difficulty. You are amazing! Thanks!

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。