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

  1. Trefwwv表示:

    Сколько стоит диплом высшего и среднего образования и как это происходит?

    allsportime.ru/gde-kupit-diplom-byistro-i-bezopasno

  2. Diplomi_bhkl表示:

    диплом кандидата наук нового образца купить russa-diploms.ru .

  3. Diplomi_vdMl表示:

    купить диплом звукорежиссера arusak-diploms.ru .

  4. Travismut表示:

    buy rybelsus: Buy semaglutide – order Rybelsus

  5. Trenttat表示:

    https://rybelsus.icu/# Semaglutide pharmacy price
    ed devices

  6. Charleszed表示:

    Plavix generic price: clopidogrel pills – buy clopidogrel online

  7. LAZER888表示:

    Everything is very open with a really clear explanation of the challenges. It was definitely informative. Your site is useful. Many thanks for sharing!

  8. Travismut表示:

    Buy semaglutide: Semaglutide pharmacy price – rybelsus price

  9. Trenttat表示:

    https://clopidogrel.pro/# antiplatelet drug
    erectile dysfunction pills

  10. Diplomi_rtMl表示:

    купить дипломы техникума цена купить дипломы техникума цена .

  11. франшиза купить готовый бизнес недорого франшиза купить готовый бизнес недорого .

  12. I’m impressed by The ability to convey such nuanced ideas with clarity.

  13. I’m always excited to see The posts in my feed. Another excellent article!

  14. Travismut表示:

    paxlovid for sale: paxlovid india – paxlovid for sale

  15. Trenttat表示:

    http://clopidogrel.pro/# Cost of Plavix without insurance
    amoxicillin without a doctor’s prescription

  16. Полезный сервис быстрого загона ссылок сайта в индексация поисковой системы – быстрая индексация ссылок

  17. Arthurfrunc表示:

    https://stromectol1st.shop/# ivermectin price canada
    Online medicine order

  18. Lazrzjz表示:

    Покупка диплома о среднем полном образовании: как избежать мошенничества?

    n-staff.ru/forum?mode=edit&type=thread&forum_id=74041

  19. вывод из запоя на дому ростов недорого http://vyvod-iz-zapoya-rostov115.ru .

  20. I have witnessed that service fees for on-line degree authorities tend to be an awesome value. Like a full Bachelor’s Degree in Communication from The University of Phoenix Online consists of 60 credits at $515/credit or $30,900. Also American Intercontinental University Online makes available Bachelors of Business Administration with a entire course element of 180 units and a tuition fee of $30,560. Online learning has made getting the college diploma far more easy because you can certainly earn your degree from the comfort of your house and when you finish working. Thanks for all your other tips I have certainly learned through the blog.

  21. Pretty! This has been an extremely wonderful post. Thanks for providing this info.

  22. Профессиональный сервисный центр по ремонту духовых шкафов в Москве.
    Мы предлагаем: ремонт дверцы духового шкафа
    Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!

發佈留言

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