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

  1. саженцы почтой наложенным платежом http://rodnoisad.ru/ .

  2. онлайн казино беларусь онлайн казино беларусь .

  3. bokep jepang表示:

    I quite like looking through a post that will make people think. Also, many thanks for allowing for me to comment.

  4. Can I just say such a relief to get one who in fact knows what theyre dealing with online. You actually know how to bring a difficulty to light and make it crucial. More and more people really need to check this out and can see this side of the story. I cant believe youre no more well-known simply because you definitely have the gift.

  5. I was able to find good info from your content.

  6. Can I say that of a relief to uncover somebody that truly knows what theyre preaching about on the net. You actually realize how to bring a concern to light making it essential. The diet have to check out this and can see this side with the story. I cant think youre no more popular when you certainly hold the gift.

  7. bokep sma表示:

    I used to be able to find good information from your content.

  8. Greetings! I know this is kinda off topic but I was wondering which blog platform are you using for this website? I’m getting tired of WordPress because I’ve had issues with hackers and I’m looking at alternatives for another platform. I would be fantastic if you could point me in the direction of a good platform.

  9. bokep sma表示:

    You ought to be a part of a contest for one of the highest quality blogs on the web. I’m going to recommend this blog!

  10. Если вы искали где отремонтировать сломаную технику, обратите внимание – профи услуги

  11. Wow, amazing blog layout! How long have you been blogging for? you make blogging look easy

  12. Your style is really unique in comparison to other folks I’ve read stuff from. Thank you for posting when you have the opportunity, Guess I will just book mark this site.

  13. The subsequent time I learn a weblog, I hope that it doesnt disappoint me as much as this one. I imply, I know it was my choice to read, however I truly thought youd have one thing fascinating to say. All I hear is a bunch of whining about something that you would fix should you werent too busy searching for attention.

  14. Если вы искали где отремонтировать сломаную технику, обратите внимание – техпрофи

  15. JVB Системные расстановки | Санкт-Петербург. https://rasstanovkiural.ru

  16. Hiya, I’m really glad I’ve found this info. Nowadays bloggers publish just about gossips and net and this is actually annoying. A good web site with exciting content, that’s what I need. Thank you for keeping this web-site, I’ll be visiting it. Do you do newsletters? Can not find it.

  17. Thank you for another fantastic blog. Where else might one get that sort of knowledge written in such a perfect way? I actually have a presentation that i’m presently acting on, and i are yearning for such info instead.

  18. Sazrfwj表示:

    Здравствуйте!
    Купить документ института
    kellerscrossing.com/

  19. Whats up, I’m ranking high for “free justin bieber stuff”.

  20. Cazrcuv表示:

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

  21. “”Its always good to learn tips like you share for blog posting. As I just started posting comments for blog and facing problem of lots of rejections. I think your suggestion would be helpful for me. I will let you know if its work for me too.”

  22. I just added this weblog to my google reader, great stuff. Cannot get enough!

  23. I’m new to your blog and i really appreciate the nice posts and great layout.:,*”-

  24. Nice post. I be taught one thing more challenging on totally different blogs everyday. It should always be stimulating to read content material from other writers and apply a bit one thing from their store. I desire to make use of some with the content on my blog whether or not you don’t mind. Natually I give you a link in your internet blog. Thanks for sharing.

  25. You’ll find some intriguing points in time in this post but I do not know if I see all of them center to heart. There is certainly some validity but I will take hold opinion until I look into it further. Excellent post , thanks and we want more! Added to FeedBurner too

  26. Uazrwfq表示:

    Привет,друзья!
    Купить диплом о высшем образовании.
    telegra.ph/diplom-kupit-minsk-08-13-6

發佈留言

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