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

8,400 Responses

  1. JefferyTar表示:

    treatment of ed: Canada pharmacy online – canada ed drugs

  2. Jamiecaw表示:

    https://mexicanpharmgate.com/# mexico drug stores pharmacies

  3. Uazrjrm表示:

    Официальная покупка диплома вуза с сокращенной программой обучения в Москве

    privatzaem.ru/kupit-attestat-v-yuzhno-sahalinske-1.html

  4. The grace and authority with which you handle topics are awe-inspiring. I always come away with new knowledge.

  5. GlennSnofs表示:

    online drugs Canadian pharmacy best prices prescription drugs

  6. Тут можно преобрести купить противопожарный сейф несгораемый сейф цена

  7. The article was a delightful read. It’s clear you’re passionate about what you do, and it shows.

  8. вывод. из. запоя. ростов. на. дону. https://www.bisound.com/forum/showthread.php?t=688674 .

  9. I appreciate the clarity and thoughtfulness you bring to this topic.

  10. нарколог на дом вывод из запоя ростов [url=www.severussnape.borda.ru/?1-4-0-00000313-000-0-0-1730648539]www.severussnape.borda.ru/?1-4-0-00000313-000-0-0-1730648539[/url] .

  11. Quotes表示:

    We recommend exploring the best quotes collections: Only Love Quotes From Great People

  12. Jamiecaw表示:

    https://canadiandrugsgate.com/# injections for ed

  13. нарколог на дом вывод из запоя ростов https://uaforum.ukrbb.net/viewtopic.php?f=13&t=3233 .

  14. вывод из запоя дешево ростов на дону http://www.automobilist.forum24.ru/?1-19-0-00000135-000-0-0-1730648713 .

  15. вывод из запоя стационар ростов https://www.ya.7bb.ru/viewtopic.php?id=14592#p40831 .

  16. TULFAFI表示:

    Http. Signal app. Jonah hill movies. Irvine ca. Carbohydrates. Purpura. Lathe. 7th amendment. Big 10. Nurse shark. Linked. John gotti. Bruce willis movies. Breaking bad cast. Harry potter and the sorcerers stone. Beverly hillbillies. Time in nigeria. Chia pet. Conan o’brien. Cynthia nixon. Chicken pox. Jean tatlock. Context. Dream. Vocabulary. Eminem. Cleveland guardians. 007 movies in order. Apocalypse. Utilitarianism. Fredericksburg va. Diaphragm. Effervescent. Roulette. Everybody wants some. Always sunny. Apprehension. Free bird. Shinjuku. Norwegian. Errol flynn. Julia louis dreyfus. Cytokinesis. Pipe. Time magazine. Steve nash. Channing tatum. Palestine. Captain marvel. John hopkins. It’s. Milwaukee journal sentinel. Twin peaks cast. Swiss air. Laredo. Zen. Harry potter books in order. Mine. Mark. Enamored. Chile. Analysis. The passion of the christ. https://liszqjq.filmfilmfilm.eu/BRDSR.html
    Bog. Mount rainier. Jai alai. Peter boyle. Episcopal church. Tar. Cinco de mayo. Hubris definition. Yu gi oh. Constellation. Levi jeans. Steely dan. Fathom. Patrick mahomes. University of washington. Cast of napoleon.movie. Protractor. Bernadette peters. Lux. Poughkeepsie. Anaheim. Rococo. Bracket. Special. Beowulf. Alcoholism. Cast of hidden figures. The washington post. Scream 1996. Iga Е›wiД…tek. Academy. Sean young. Addisons disease. University of maryland. Garland. Mike johnson. Form 1040. Alan dershowitz. Natural selection. Louis tomlinson. Los angeles time. Murad. Commitment. Rocket. Tesla news. Wrigley field. Warsaw. Catch me if you can. Lea michele. Lemon tree. Beastie boys. Montgomery ward. Damian lewis. Or. Civil rights act of 1964. Lincoln. Recommend. Ideology. Felix the cat. Russian flag. Park city. Mary shelley. Tempo.

  17. Lazrxdh表示:

    Легальные способы покупки диплома о среднем полном образовании
    чпуремонт.рф/showthread.php?tid=108105

  18. вывод из запоя на дому ростов на дону вывод из запоя на дому ростов на дону .

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

發佈留言

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