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

19,693 Responses

  1. What made you first develop an interest in this topic?

  2. Cthrinepisn表示:

    help writing a compare and contrast essay
    essay conclusion help
    essay proofreading service

  3. bhutani表示:

    This is something that will need all of our combined efforts to address.

  4. Cthrinepisn表示:

    editing essay services
    your essay writer
    online essay writers

  5. Leilahpisn表示:

    reflective essay help
    college application essay writing help
    service essays

  6. Wish I’d thought of this. Am in the field, but I procrastinate alot and haven’t written as much as I’d like. Thanks.

  7. Leilahpisn表示:

    college essay writing company
    cheap essay writer
    help with essays assignments

  8. This is something that will need all of our combined efforts to address.

  9. Just want to say what a great blog you got here!I’ve been around for quite a lot of time, but finally decided to show my appreciation of your work!

  10. Hi my family member! I want to say that this article is amazing, great written and include approximately all important infos. I’d like to see more posts like this .

  11. Leilahpisn表示:

    good essay writers
    essay writing services toronto
    help writing essays

  12. Twylapisn表示:

    essay writing services scams
    write my essay for me no plagiarism
    custom essay writing sites

  13. Twylapisn表示:

    the best essay writing services
    online essay editing service
    service learning reflection essay

  14. Twylapisn表示:

    recommended essay writing service
    essay writer cheap
    cheapest essay writing services

  15. Dronapisn表示:

    custom essay service toronto
    student essay help
    write my essay generator

  16. Dronapisn表示:

    can somebody write my essay
    online custom essays
    academic essay help

  17. Dronapisn表示:

    professional essay writers review
    english essay help
    research essay help

  18. Charopisn表示:

    legitimate essay writing services
    services essay
    custom essay writing online

  19. Charopisn表示:

    need help writing essay
    best essay writing websites
    essay help chat room

  20. informate表示:

    Thank you a lot for sharing this with all folks you actually recognize what you’re speaking about! Bookmarked. Please additionally visit my site =). We can have a hyperlink trade contract among us!

  21. llaves pisos表示:

    Easily, the post is really the greatest on this laudable topic. I concur with your conclusions and will thirstily look forward to your future updates. Saying thank will not just be sufficient, for the wonderful c lucidity in your writing. I will instantly grab your rss feed to stay privy of any updates. Solid work and much success in your business enterprise!

  22. Charopisn表示:

    buy custom essays
    lord of the flies essay help
    write my history essay for me

  23. Rhiamonpisn表示:

    top custom essay services
    cheapest essay writing services
    custom law essays

  24. Rhiamonpisn表示:

    help writing a college essay
    essay writing help online
    professional essay help

  25. Rhiamonpisn表示:

    help writing college application essay
    essay writing services recommendations
    professional custom essays

  26. Antoniepisn表示:

    business school essay writing service
    best online essay writers
    professional essay help

  27. Antoniepisn表示:

    essay writer online
    help with writing college essays
    history essay help

  28. The start of a fast-growing trend?

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

  30. Antoniepisn表示:

    essay assignment help
    writing essays services
    buy custom essay online

發佈留言

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