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

3,141 Responses

  1. Our local network of agencies has found your research so helpful.

  2. leer mas表示:

    Im impressed. I dont think Ive met anyone who knows as much about this subject as you do. Youre truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog youve got here.

  3. It is perfect 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 want to suggest you some interesting things or suggestions. Perhaps you can write next articles referring to this article. I wish to read more things about it!

  4. I do believe your audience could very well want a good deal more stories like this carry on the excellent hard work.

  5. Katinepisn表示:

    jackpot magic slots blog
    real casino free slots
    free slots online

  6. canada cialis表示:

    pcos clomid success where can i buy clomid pills does clomid work for everyone when should i start taking clomid

  7. kamagra vs cialis comparateur prix cialis cialis+avis des internautes forum ou acheter cialis en ligne

  8. Cool Designs表示:

    I came across an article that talks about the same thing but even more and when you go deeper.

  9. Hey! Do you know if they make any plugins to protect against hackers? I’m kinda paranoid about losing everything I’ve worked hard on. Any suggestions?

  10. It’s clear you’re passionate about the issues.

  11. kamagra livraison rapide medicament kamagra kamagra pour homme effet secondaire kamagra ou priligy

  12. Keep it up!. I usually don’t post in Blogs but your blog forced me to, amazing work.. beautiful A rise in An increase in An increase in.

  13. NFT Generator表示:

    Just a quick note to express my appreciation. Take care

  14. where can i get cenforce 100 getting cenforce without a prescription buy cenforce 120mg cenforce 150 red pill

  15. Substantially, the post is really the best on this laudable topic. I concur with your conclusions and will eagerly watch forward to your future updates.Just saying thanx will not just be enough, for the wonderful lucidity in your writing.

  16. hypertension et kamagra kamagra en ligne peut on acheter du kamagra sans ordonnace cialis ou kamagra ou levitra

  17. I’ve read several good stuff here. Definitely worth bookmarking for revisiting. I surprise how much effort you put to make such a magnificent informative site.

  18. cartia drug表示:

    results of viagra name brand viagra does viagra make you bigger what levitra is used for

  19. have already been reading ur blog for a couple of days. really enjoy what you posted. btw i will be doing a report about this topic. do you happen to know any great websites or forums that I can find out more? thanks a lot.

  20. I like this web blog very much, Its a real nice berth to read and get information. “I have found that if you love life, life will love you back.” by Arthur Rubinstein.

  21. levitra sublingual levitra does bayer make levitra generic levitra usa

  22. prostigimine and zanaflex tizanidine 4 mg capsule coupon zanaflex daily dosage long term what is a dangerous dose of zanaflex

  23. zstqeyeh表示:

    https://www.hydroxychloroquinex.com/ buy hydroxychloroquine sulfate online

  24. If wings are your thing, Tinker Bell’s sexy Halloween costume design is all grown up.

  25. Amazing! Your site has quite a few comment posts. How did you get all of these bloggers to look at your site I’m envious! I’m still studying all about posting articles on the net. I’m going to view pages on your website to get a better understanding how to attract more people. Thank you!

  26. Could not disagree with the main ideas. Wonder how things will develop over the coming years.

  27. I would really like to appreciate the endeavors you cash in on written this article. I’m going for the similar best product from you finding out in the foreseeable future as well. Actually your creative writing abilities has urged me to begin my very own blog now. Genuinely the blogging is distributing its wings rapidly. Your write down is often a fine illustration showing it.

  1. 2022-06-30

    2contagious

發佈回覆給「xjplkjzz」的留言 取消回覆

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