이 예제는 HTML5 캔버스 시뮬레이션 웹 로딩 인스턴스입니다. 렌더링은 다음과 같습니다.
예제 코드 : (미리보기 주소 : http://html5demos.com/canvas)
- <! doctypehtml>
- <htmllang = enxmlns = http : //www.w3.org/1999/xhtml>
- <헤드>
- <metahttp-equiv = content-typecontent = text/html; charset = utf-8/>
- <title> html5demo : 캔버스 </title>
- <스타일>
- 몸{
- 글꼴 : normal16px/20pxhelvetica, sans-serif;
- 배경 : RGB (237,237,236);
- 여백 : 0;
- 마진-탑 : 40px;
- 패딩 : 0;
- }
- 기사, 섹션, 헤더, 바닥 글 {
- 디스플레이 : 블록;
- }
- #싸개{
- 너비 : 600px;
- 여백 : 0auto;
- 배경 : #fffurl (images/shade.jpg) 반복-XCENTERBOTTOM;
- -Moz 국경 Radius : 10px;
- -webkit-border-radius : 10px;
- 테두리 : 1pxSolid#ffff;
- 패딩 바닥 : 76px;
- }
- H1 {
- 패딩 탑 : 10px;
- }
- H2 {
- 글꼴 크기 : 100%;
- 글꼴 스타일 : 이탈리아;
- }
- 헤더,
- 기사>*,
- 풋 테라,
- 바닥 글 {
- 마진 : 20px;
- }
- 바닥 글>*{
- 마진 : 20px;
- 색상 :#999;
- }
- 기사{
- 위치 : 상대;
- }
- </스타일>
- <cript>
- //fordiscussionandcomments, see:http://remysharp.com/2009/01/07/html5-enabling-script/
- (function () {if (!/*@cc_on!@*/0) return; vare = abbr, article, article, audio, bb, canvas, datagrid, datalist, 세부 사항, 대화, 이벤트 소스, 그림, foo Ter, Header, Mark, Menu, Meter, Nav, Nav, 출력, 진행, 섹션, Time, Video.split ( ','), i = e.length; while (i-) {document.createElement (e [i])}) ()
- </스크립트>
- </head>
- <body>
- <sectionid = 래퍼>
- <Header>
- <H1> 캔버스 </h1>
- </헤더>
- <기사> </article>
- <FUTER> <ahref =/> html5demo </a> </풋내기>
- </섹션>
- <scriptsrc = h5utils.js> </script>
- <cript>
- buildSpinner ({x : 50, y : 50, 크기 : 20,도 : 30});
- functionBuildSpinner (데이터) {
- varcanvas = document.createElement ( 'canvas');
- Canvas.height = 100;
- Canvas.width = 300;
- document.getElementsByTagName ( 'article') [0] .AppendChild (캔버스);
- varctx = canvas.getContext (2d),
- i = 0, ecress = data.degrees, loops = 0, exgreeslist = [];
- for (i = 0; i <도; i ++) {
- fegreeslist.push (i);
- }
- //다시 놓기
- i = 0;
- // SOICANKILLITLATER
- window.canvastimer = setInterval (드로우, 1000/도);
- functionset () {
- ctx.clearrect (0,0,100,100); // clearcanvas
- varleft = degreeslist.slice (0,1);
- varright = degreeslist.slice (1, degreeslist.length);
- gegreeslist = right.concat (왼쪽);
- }
- functiondraw () {
- varc, s, e;
- vard = 0;
- if (i == 0) {
- 다시 놓기();
- }
- ctx.save ();
- d = thegreeslist [i];
- C = Math.floor (255/도*i);
- ctx.strokestyle = 'rgb ('+c+','+c+','+c+')';
- ctx.linewidth = data.size;
- ctx.beginpath ();
- s = math.floor (360/도*(d));
- e = math.floor (360/도*(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> =도) {
- i = 0;
- }
- }
- }
- </스크립트>
- <cript>
- vargajshost = ((https : == document.location.protocol)? https : // ssl. : http : // www.);
- document.write (unescape (%3cscriptsrc = '+gajshost+google-analytics.com/ga.js'type ='text/javaScript '%3e%3c/script%3e);
- </스크립트>
- <cript>
- 노력하다{
- varpagetracker = _gat._getTracker (UA-1656750-18);
- pagetracker._trackPageView ();
- } catch (err) {} </script>
- </body>
- </html>