Этот пример представляет собой экземпляр загрузки веб -загрузки 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: canvas </title>
- <style>
- тело{
- Шрифт: нормальный16px/20pxhelvetica, sans-serif;
- Предпосылки: RGB (237 237 236);
- поля: 0;
- маржинальная версия: 40px;
- Заполнение: 0;
- }
- Статья, раздел, заголовок, нижний колонтитул {
- дисплей: блок;
- }
- #wrapper {
- Ширина: 600px;
- Маржа: 0Auto;
- Фон: #fffurl (image/shade.jpg) Repeat-xcenterbottom;
- -Моз-грамотный радий: 10px;
- -Вебкит-грамотный радий: 10px;
- Пограничная топ: 1pxsolid#ffff;
- надоеволос: 76px;
- }
- H1 {
- надоеволок: 10px;
- }
- H2 {
- размер шрифта: 100%;
- в стиле шрифта: курсив;
- }
- заголовок,
- Статья>*,
- манера,
- нижняя часть {
- Маржа: 20px;
- }
- нижний колонтитул>*{
- Маржа: 20px;
- Цвет:#999;
- }
- статья{
- позиция: относительно;
- }
- </style>
- <Скрипт>
- //Fordiscussionandcomments, см .:http://remysharp.com/2009/01/07/html5-enabling-script/
- (function () {if (!/*@cc_on!@*/0) return; vare = abbr, article, в сторону, аудио, BB, Canvas, DataGrid, Datalist, детали, диалог, Eventsource, Figure, Foo Тер, заголовок, марка, меню, счетчик, навигация, вывод, прогресс, раздел, время, видео.
- </script>
- </head>
- <тело>
- <sectionid = warper>
- <заголовок>
- <h1> canvas </h1>
- </header>
- <статья> </article>
- <gooler> <ahref =/> html5demo </a> </cooler>
- </section>
- <scriptsrc = h5utils.js> </script>
- <Скрипт>
- BuildSpinner ({x: 50, y: 50, размер: 20, градусы: 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 = [];
- для (i = 0; i <градусов; 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) {
- перезагрузить();
- }
- ctx.save ();
- d = degreeslist [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;
- }
- }
- }
- </script>
- <Скрипт>
- 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));
- </script>
- <Скрипт>
- пытаться{
- varPageTracker = _gat._getTracker (UA-1656750-18);
- pagetracker._trackpageview ();
- } catch (err) {} </script>
- </body>
- </html>