この例は、HTML5キャンバスシミュレーションWebロードロードインスタンスです。レンダリングは次のとおりです。
例コード:(プレビューアドレス:http://html5demos.com/canvas)
- <!doctypehtml>
- <htmllang = enxmlns = http://www.w3.org/1999/xhtml>
- <head>
- <metahttp-equiv = content-typecontent = text/html; charset = utf-8/>
- <title> html5demo:canvas </title>
- <style>
- 体{
- フォント:normal16px/20pxhelvetica、sans-serif;
- 背景:RGB(237,237,236);
- マージン:0;
- マージントップ:40px;
- パディング:0;
- }
- 記事、セクション、ヘッダー、フッター{
- 表示:ブロック;
- }
- #wrapper {
- 幅:600px;
- マージン:0auto;
- 背景:#fffurl(images/shade.jpg)Repeat-XcenterBottom;
- -moz-border-radius:10px;
- -webkit-border-radius:10px;
- ボーダートップ:1pxSolid#ffff;
- パディングボトム:76px;
- }
- H1 {
- パディングトップ:10px;
- }
- H2 {
- フォントサイズ:100%;
- フォントスタイル:イタリック;
- }
- ヘッダ、
- 記事>*、
- フッター、
- footerp {
- マージン:20px;
- }
- フッター>*{
- マージン:20px;
- 色:#999;
- }
- 記事{
- 位置:相対;
- }
- </style>
- <スクリプト>
- //fordiscussionandcomments、see:http://remysharp.com/2009/01/07/html5-enabling-script/
- (function(){if(!/*@cc_on!@*/0)return; vare = abbr、aftion、adas、audio、bb、canvas、datagrid、datalist、details、dialog、eventsource、figure、foo ter、ヘッダー、マーク、メニュー、メーター、nav、output、progress、section、time、video.split( '、')、i = e.length; while(i-){document.createelment(e [i])}})(
- </script>
- </head>
- <body>
- <sectionId = wrapper>
- <ヘッダー>
- <h1> canvas </h1>
- </header>
- <記事> </記事>
- <footer> <ahref =/> html5demo </a> </footer>
- </section>
- <scriptsrc = h5utils.js> </script>
- <スクリプト>
- buildspinner({x:50、y:50、size:20、degrees:30});
- functionbuildspinner(data){
- varcanvas = document.createelement( 'canvas');
- canvas.height = 100;
- canvas.width = 300;
- document.getElementsByTagname( 'article')[0] .appendChild(canvas);
- varctx = canvas.getContext(2d)、
- i = 0、degrees = data.degrees、loops = 0、degreeslist = [];
- for(i = 0; i <degrees; i ++){
- degreeslist.push(i);
- }
- //リセット
- i = 0;
- // soicankillitlater
- window.canvastimer = setInterval(描画、1000/度);
- functionreset(){
- CTX.ClearRect(0,0,100,100); // ClearCanvas
- varleft = degreeslist.slice(0,1);
- varright = degreeslist.slice(1、degreeslist.length);
- degreeslist = right.concat(左);
- }
- functiondraw(){
- varc、s、e;
- vard = 0;
- if(i == 0){
- reset();
- }
- ctx.save();
- d = degreeslist [i];
- c = math.floor(255/degrees*i);
- ctx.strokestyle = 'rgb('+c+'、'+c+'、'+c+')';
- ctx.linewidth = data.size;
- ctx.beginpath();
- s = math.floor(360/degrees*(d));
- e = math.floor(360/degrees*(d+1))-1;
- ctx.arc(data.x、data.y、data.size、(math.pi/180)*s、(math.pi/180)*e、false);
- ctx.stroke();
- ctx.restore();
- i ++;
- if(i> = degrees){
- i = 0;
- }
- }
- }
- </script>
- <スクリプト>
- vargajshost =((https:== document.location.protocol)?https:// ssl。:http:// www。);
- document.write(unescape(%3cscriptsrc = '+gajshost+google-analytics.com/ga.js's'type =' text/javascript '%3e%3c/script%3e));
- </script>
- <スクリプト>
- 試す{
- varpageTracker = _gat._getTracker(UA-1656750-18);
- pagetracker._trackpageview();
- } catch(err){} </script>
- </body>
- </html>