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

6,938 Responses

  1. I was just seeking this information for a while. After six hours of continuous Googleing, finally I got it in your website. I wonder what is the lack of Google strategy that do not rank this type of informative web sites in top of the list. Usually the top sites are full of garbage.

  2. safe scaff表示:

    retinoid is always one of the best medication that you can use on your skin.

  3. I am perpetually thought about this, appreciate it for posting .

  4. Youre so cool! I dont suppose Ive read anything like this before. So nice to find any individual with some authentic ideas on this subject. realy thanks for beginning this up. this website is something that’s needed on the web, somebody with somewhat originality. helpful job for bringing one thing new to the web!

  5. Thank you, I have just been looking for information about this subject for ages and yours is the best I’ve discovered so far. But, what about the bottom line? Are you sure about the source?

  6. Hey there! I could have sworn I’ve gone to this site before but after checking through some of the posts I realized it’s brand new to me. Anyhow, I’m definitely thrilled I discovered it and I’ll be bookmarking and checking back regularly!

  7. I wanted to thank you for this great read!! I absolutely enjoyed
    evry little bit of it. I’ve got you bookmarked to check out new things you post…

  8. Good Post, I am a big believer in writing comments on weblogs to let the blog writers know that they’ve added some thing of great benefit to the world wide web!

  9. Can I simply say exactly what a relief to get somebody who really knows what theyre referring to on the net. You definitely learn how to bring an issue to light and make it crucial. More and more people should check out this and see why side in the story. I cant think youre less popular because you certainly hold the gift.

  10. Thanks for your blog post. I would also like to say that the health insurance broker also works well with the benefit of the coordinators of a group insurance policy. The health insurance agent is given a listing of benefits searched for by individuals or a group coordinator. What a broker may is look for individuals or perhaps coordinators which usually best match up those requirements. Then he provides his ideas and if both parties agree, the actual broker formulates a contract between the two parties.

  11. There is noticeably a bundle to understand this. I suppose you have made specific nice points in features also.

  12. I likewise conceive so , perfectly written post! .

  13. I haven’t checked in here for a while since I thought it was getting boring, but the last few posts are great quality so I guess I will add you back to my daily bloglist. You deserve it friend

  14. Nice post. I understand some thing tougher on different blogs everyday. It will always be stimulating to see content from other writers and practice something at their store. I’d prefer to use some with the content in my blog regardless of whether you don’t mind. Natually I’ll provide link on your web weblog. Thank you for sharing.

  15. We absolutely love your blog and find nearly all of your post’s to be precisely what I’m looking for. Would you offer guest writers to write content to suit your needs? I wouldn’t mind producing a post or elaborating on many of the subjects you write about here. Again, awesome web log!

  16. tubidy mp3表示:

    This website was… how do I say it? Relevant!! Finally I have found something which helped me. Thanks.

  17. Youre so cool! I dont suppose Ive read anything such as this just before. So nice to find somebody with many original ideas on this subject. realy appreciation for starting this up. this web site is one thing that is needed over the internet, someone if we do originality. beneficial job for bringing something totally new for the world wide web!

  18. The following time I read a weblog, I hope that it doesnt disappoint me as a lot as this one. I mean, I know it was my option to learn, but I actually thought youd have one thing fascinating to say. All I hear is a bunch of whining about something that you would repair when you werent too busy in search of attention.

  19. BR sells their items under five applications with name of ice cream, cakes, sundaes, beverages and prepacks. They have other promotional packages individually or as subprogram of any other programs.

  20. Fantastic post, I’ve bookmarked this page and have a feeling I’ll be returning to it normally.

  21. Diplomi_mlOa表示:

    купить диплом ссср https://school-10-lik.ru .

  22. Hello there, just became aware of your blog through Google, and found that it’s truly informative. I’m going to watch out for brussels. I’ll be grateful if you continue this in future. Many people will be benefited from your writing. Cheers!

  23. I really like reading a post that will make men and women think. Also, thanks for allowing me to comment.

  24. very good post, i certainly adore this site, persist with it

  25. Aw, i thought this was an exceptionally nice post. In thought I have to devote writing like that moreover – taking time and actual effort to have a really good article… but so what can I say… I procrastinate alot by no indicates apparently go accomplished.

  26. Hey! Good stuff, do tell us when you finally post something like this!

  27. I can’t imagine focusing long enough to research; much less write this kind of article. You’ve outdone yourself with this material. This is great content.

  28. Some truly good content on this web site , appreciate it for contribution.

  29. Wow! Thank you! I always wanted to write on my site something like that. Can I include a portion of your post to my website?

發佈留言

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