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

7,786 Responses

  1. TomasRop表示:

    Farmacia online miglior prezzo: Cialis generico 20 mg 8 compresse prezzo – farmacia online

  2. Mazreju表示:

    Привет!
    Вопросы и ответы: можно ли быстро купить диплом старого образца?
    rushkadiplomiks.ru/kupit-diplom-novosibirsk

  3. RandyLunda表示:

    acquisto farmaci con ricetta: Avanafil a cosa serve – migliori farmacie online 2024

  4. Timothyzew表示:

    http://kamagrait.pro/# comprare farmaci online all’estero

  5. TomasRop表示:

    farmacie online affidabili: kamagra gel prezzo – comprare farmaci online con ricetta

  6. I am continuously searching online for ideas that can benefit me. Thx!

  7. I am impressed with this site, real I am a fan .

  8. RandyLunda表示:

    viagra generico in farmacia costo: viagra originale in 24 ore contrassegno – viagra prezzo farmacia 2023

  9. Whitescreen57表示:

    Excellent article. I absolutely love this website. Stick with it!

  10. Hello, Neat post. There is a problem with your site in web explorer, might check this… IE nonetheless is the marketplace leader and a big component to other people will omit your wonderful writing due to this problem.

  11. I appreciate, cause I found exactly what I was looking for. You’ve ended my four day long hunt! God Bless you man. Have a great day. Bye

  12. TomasRop表示:

    viagra originale in 24 ore contrassegno: acquisto viagra – alternativa al viagra senza ricetta in farmacia

  13. Mazrprq表示:

    Добрый день!
    Как официально купить аттестат 11 класса с упрощенным обучением в Москве
    rushkadiplomik.ru

  14. RandyLunda表示:

    alternativa al viagra senza ricetta in farmacia: viagra senza prescrizione – gel per erezione in farmacia

  15. Timothyzew表示:

    http://viagragenerico.site/# dove acquistare viagra in modo sicuro

  16. Hello there! I know this is somewhat off topic but I was wondering which blog platform are you using for this site? I’m getting tired of WordPress because I’ve had problems with hackers and I’m looking at options for another platform. I would be fantastic if you could point me in the direction of a good platform.

  17. Hello there! Nice post! Please inform us when all could see a follow up!

  18. Oh my goodness! a fantastic post dude. Thanks However My business is experiencing issue with ur rss . Do not know why Struggling to join it. Is there anybody getting identical rss issue? Anyone who knows kindly respond. Thnkx

  19. TomasRop表示:

    migliori farmacie online 2024: comprare farmaci online all’estero – farmacia online piГ№ conveniente

  20. 카지노톡表示:

    When I originally left a comment I appear to have clicked the -Notify me when new comments are added- checkbox and from now on every time a comment is added I recieve four emails with the exact same comment. There has to be an easy method you can remove me from that service? Appreciate it.

  21. RandyLunda表示:

    acquistare farmaci senza ricetta: Farmacie che vendono Cialis senza ricetta – farmacie online affidabili

  22. Sazrjum表示:

    Добрый день!
    Диплом о высшем образовании
    mireait.listbb.ru/viewtopic.php?f=2&t=492

  23. Thanks for the sensible critique. Me & my neighbor were just preparing to do some research on this. We got a grab a book from our local library but I think I learned more from this post. I’m very glad to see such fantastic info being shared freely out there.

  24. Youre so cool! I dont suppose Ive read something like this before. So nice to seek out somebody with some original thoughts on this subject. realy thanks for starting this up. this web site is one thing that’s wanted on the net, somebody with somewhat originality. helpful job for bringing one thing new to the web!

  25. satellite tv has got to be one of the best inventions that we humans enjoy,,

  26. Spot on with this write-up, I truly suppose this website needs way more consideration. I’ll most likely be once more to learn rather more, thanks for that info.

  27. Mazrdod表示:

    Добрый день!
    Приобретение диплома ПТУ с сокращенной программой обучения в Москве
    rushkadiplomik.ru

  28. It is appropriate time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I desire to suggest you some interesting things or suggestions. Maybe you could write next articles referring to this article. I want to read more things about it!

發佈留言

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