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

19,536 Responses

  1. Brucevaf表示:

    zithromax 500 without prescription: buy cheap generic zithromax – where to get zithromax over the counter

  2. DavidFrels表示:

    buy cytotec over the counter: cytotec online – order cytotec online

  3. Jamesarill表示:

    http://lisinoprilbestprice.store/# lisinopril 10 mg without prescription

  4. Brandonjat表示:

    purchase zithromax online zithromax 500 price zithromax 250mg

  5. StevenZen表示:

    zithromax 500 without prescription: zithromax over the counter uk – zithromax for sale usa

  6. DavidFrels表示:

    buy cytotec pills: buy cytotec pills online cheap – buy cytotec online fast delivery

  7. BobbyPem表示:

    http://doxycyclinebestprice.pro/# generic for doxycycline

  8. Смотреть фильм воспоминание. Для обозначения совокупности социально значимых качеств человека.
    Мемориз это. Виды образных явлений.
    Тест какой ты под. Современные дети текст.

  9. DavidFrels表示:

    zithromax 500 mg lowest price online: zithromax over the counter canada – generic zithromax online paypal

  10. Jamesarill表示:

    http://cytotec.icu/# buy misoprostol over the counter

  11. StevenZen表示:

    Abortion pills online: Cytotec 200mcg price – buy cytotec over the counter

  12. DavidFrels表示:

    tamoxifen effectiveness: hysterectomy after breast cancer tamoxifen – tamoxifen cyp2d6

  13. eSygxS表示:

    Bethenny Getting Married documented her relationship and subsequent marriage to Hoppy, and Bethenny Ever After followed the birth of their daughter levitra ou viagra Anyway, IVF worked for me and I m now pregnant with twins

  14. Michaeltaisa表示:

    http://amoxil.icu/# buy amoxicillin 500mg capsules uk

  15. Michaeltaisa表示:

    https://amoxil.icu/# price of amoxicillin without insurance

  16. MichaelSom表示:

    where to get clomid: can i buy clomid without a prescription – buying cheap clomid without insurance

  17. Timothyket表示:

    prednisone daily use: order prednisone online no prescription – prednisone buy canada

  18. Antoniobus表示:

    http://ciprofloxacin.life/# buy cipro cheap

  19. MichaelWence表示:

    can i get clomid without prescription can i order clomid online – cheap clomid price

  20. Danielnek表示:

    http://amoxil.icu/# amoxicillin 500mg for sale uk

  21. Timothyket表示:

    where to get prednisone: how to purchase prednisone online – 50 mg prednisone tablet

  22. Timothyket表示:

    prednisone prescription online: prednisone 20mg nz – 5 mg prednisone tablets

  23. Danielnek表示:

    https://amoxil.icu/# amoxicillin order online no prescription

  24. MichaelSom表示:

    buy cheap clomid no prescription: can i order generic clomid pill – cost clomid no prescription

  25. Michaeltaisa表示:

    http://amoxil.icu/# amoxicillin without prescription

  26. Antoniobus表示:

    https://ciprofloxacin.life/# antibiotics cipro

  27. Danielnek表示:

    https://amoxil.icu/# amoxicillin capsules 250mg

  28. MichaelWence表示:

    buy generic clomid without prescription how can i get clomid online – where can i get generic clomid now

  29. MichaelWence表示:

    can you buy clomid can i purchase cheap clomid – where buy clomid without a prescription

發佈留言

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