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,872 Responses

  1. Uazrcmg表示:

    Привет,друзья!
    Приобрести диплом любого университета.
    telegra.ph/gde-kupit-diplom-tehnikuma-08-13-3

  2. himegoto表示:

    Great blog! Do you have any tips and hints for aspiring writers? I’m planning to start my own site soon but I’m a little lost on everything. Would you recommend starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m totally confused .. Any tips? Appreciate it!

  3. Lazrsad表示:

    Привет, друзья!
    Мы можем предложить дипломы психологов, юристов, экономистов и прочих профессий по невысоким ценам.
    jurnalbest.com/index.php/mrbest/user/viewPublicProfile/113719

  4. NWS Damage Survey for Duck Creek Ranch Tornado – 6/7/2022 (Report).

  5. In 1829, David Lester Richardson went to Zimmay (Chiang Mai) to purchase cattle to feed British soldiers at Moulmein.

  6. If the restaurant has misplaced energy, but continues to be open and serving a limited, grill-only menu, that is yellow.

  7. 余韻嫋々表示:

    In all, 28 tornadoes touched down, causing at the very least three injuries.

  8. EPOS software alerts inventory managers about low inventory ranges of all products present in stock.

  9. Car monitoring programs may additionally use odometry or useless reckoning instead or complementary means of navigation.

  10. Trefqma表示:

    Здравствуйте!
    Полезная информация как официально купить диплом о высшем образовании
    fatandsassymama.com/order-a-cookbook/#comment-225370
    Рады помочь!.

  11. Oh my goodness! Awesome article dude! Many thanks, However I am having issues with your RSS. I don’t understand why I cannot join it. Is there anybody getting the same RSS issues? Anybody who knows the solution will you kindly respond? Thanks.

  12. Hi there, I found your blog via Google while searching for a related topic, your site came up, it looks good. I have bookmarked it in my google bookmarks.

  13. Good info. Lucky me I came across your site by chance (stumbleupon). I’ve bookmarked it for later.

  14. This blog was… how do you say it? Relevant!! Finally I’ve found something that helped me. Appreciate it.

  15. Xazrisg表示:

    Привет, друзья!
    Купить документ о получении высшего образования.
    Мы изготавливаем дипломы любой профессии по приятным ценам.
    student-madi.ru
    Рады оказаться полезными!.

  16. Mazramf表示:

    Привет, друзья!
    Полезная информация как купить диплом о высшем образовании без рисков
    marandola.net/dokuwiki/doku.php?id=diplomandoks

  17. Lazrayp表示:

    Привет, друзья!
    Заказать диплом университета
    vpconf.ru

  18. Hiya, I’m really glad I’ve found this info. Today bloggers publish only about gossips and internet and this is actually annoying. A good website with exciting content, that’s what I need. Thank you for keeping this site, I will be visiting it. Do you do newsletters? Cant find it.

  19. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You obviously know what youre talking about, why throw away your intelligence on just posting videos to your blog when you could be giving us something informative to read?

  20. Good information. Lucky me I recently found your site by accident (stumbleupon). I have book marked it for later!

  21. Everything is very open with a precise clarification of the issues. It was really informative. Your site is useful. Many thanks for sharing.

  22. KevinSounc表示:

    https://denemebonusuverensiteler.win/# bonus veren siteler

  23. JesusLealt表示:

    slot siteleri 2024: slot siteleri guvenilir – slot oyunlar? siteleri

  24. You’re so awesome! I do not believe I have read something like that before. So nice to find another person with genuine thoughts on this subject. Seriously.. thanks for starting this up. This site is something that is required on the internet, someone with some originality.

  25. Mazrmnw表示:

    Здравствуйте!
    Как быстро получить диплом магистра? Легальные способы
    numterra.ru/index/numerologija_deneg_kak_najti_svoj_denezhnyj_magnit/0-176

發佈留言

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