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...

13,170 Responses

  1. Davidmoits表示:

    easy canadian pharm: easy canadian pharm – easy canadian pharm

  2. WillieRap表示:

    reputable mexican pharmacies online: medication from mexico pharmacy – xxl mexican pharm

  3. Charleskepsy表示:

    canadian pharmacy coupon code https://megaindiapharm.shop/# best india pharmacy

  4. Greetings from Los angeles! I’m bored to death at work so I decided to check out your blog on my iphone during lunch break. I love the info you provide here and can’t wait to take a look when I get home. I’m shocked at how fast your blog loaded on my mobile .. I’m not even using WIFI, just 3G .. Anyways, good site!|

  5. MichaelGeony表示:

    canadian pharmacy discount coupon http://easycanadianpharm.com/# easy canadian pharm

  6. Davidmoits表示:

    escrow pharmacy canada: easy canadian pharm – reliable canadian pharmacy

  7. daman game表示:

    This design is incredible! You most certainly know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent job. I really loved what you had to say, and more than that, how you presented it. Too cool!|

  8. MichaelGeony表示:

    canadian pharmacy world coupons https://easycanadianpharm.com/# easy canadian pharm

  9. Porterfax表示:

    online pharmacy delivery usa family pharmacy online pharmacy delivery usa

  10. Davidmoits表示:

    online pharmacy delivery usa: Best online pharmacy – rx pharmacy coupons

  11. MichaelGeony表示:

    best no prescription pharmacy https://familypharmacy.company/# Cheapest online pharmacy

  12. Davidmoits表示:

    MegaIndiaPharm: Mega India Pharm – Mega India Pharm

  13. Charleskepsy表示:

    canadian pharmacy coupon https://xxlmexicanpharm.com/# xxl mexican pharm

  14. WillieRap表示:

    Mega India Pharm: Mega India Pharm – Mega India Pharm

  15. Davidmoits表示:

    reputable mexican pharmacies online: mexican pharmaceuticals online – xxl mexican pharm

  16. Charleskepsy表示:

    no prescription pharmacy paypal https://discountdrugmart.pro/# drugmart

  17. WillieRap表示:

    discount drug mart pharmacy: drug mart – discount drugs

  18. Charleskepsy表示:

    cheapest pharmacy for prescription drugs http://megaindiapharm.com/# Mega India Pharm

  19. Though ideas found in these particular papers are typically the majority of evidently applicable in the direction of group relating to loaning, they should be placed on all pursuits where credit rankings risk is present.

  20. Porterfax表示:

    top 10 pharmacies in india Mega India Pharm india online pharmacy

  21. MichaelGeony表示:

    canadian pharmacy no prescription needed http://discountdrugmart.pro/# drugmart

  22. WillieRap表示:

    MegaIndiaPharm: п»їlegitimate online pharmacies india – MegaIndiaPharm

  23. MichaelGeony表示:

    canadian pharmacy world coupon https://xxlmexicanpharm.com/# xxl mexican pharm

  24. Davidmoits表示:

    xxl mexican pharm: mexico drug stores pharmacies – xxl mexican pharm

  25. Charleskepsy表示:

    rxpharmacycoupons https://xxlmexicanpharm.com/# mexico drug stores pharmacies

  26. Porterfax表示:

    family pharmacy drugstore com online pharmacy prescription drugs Cheapest online pharmacy

  27. MichaelGeony表示:

    rx pharmacy coupons https://megaindiapharm.com/# MegaIndiaPharm

  28. Davidmoits表示:

    Mega India Pharm: top online pharmacy india – Mega India Pharm

發佈留言

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