index.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Skycons</title>
  5. <meta charset="us-ascii">
  6. <style type="text/css">
  7. body {
  8. font: 300 112.5%/1.5em "Helvetica", "Arial", sans-serif;
  9. margin: 3em 3em 6em;
  10. padding: 0;
  11. }
  12. article {
  13. margin: auto;
  14. width: 30em;
  15. }
  16. h1 {
  17. font-size: 3em;
  18. line-height: 1em;
  19. text-align: center;
  20. margin: 0.5em 0;
  21. }
  22. p {
  23. margin: 1.5em 0;
  24. }
  25. figure {
  26. margin: 3em auto;
  27. width: 368px;
  28. height: 152px;
  29. }
  30. canvas {
  31. display: block;
  32. float: left;
  33. margin-left: 8px;
  34. margin-top: 8px;
  35. }
  36. pre {
  37. font: 77.8%/1.5em "Lucida Sans Typewriter", "Lucida Console", "Monaco", "Bitstream Vera Sans Mono", monospace;
  38. margin: 3.375em 1.6875em;
  39. }
  40. a, pre span.comment {
  41. color: royalblue;
  42. }
  43. a:visited, pre span.constant {
  44. color: indianred;
  45. }
  46. </style>
  47. </head>
  48. <body>
  49. <article>
  50. <h1>Skycons</h1>
  51. <p><strong>Skycons</strong> is a set of ten animated weather glyphs,
  52. procedurally generated by JavaScript using the HTML5 canvas tag.</p>
  53. <figure class="icons">
  54. <canvas id="clear-day" width="64" height="64">
  55. </canvas>
  56. <canvas id="clear-night" width="64" height="64">
  57. </canvas>
  58. <canvas id="partly-cloudy-day" width="64" height="64">
  59. </canvas>
  60. <canvas id="partly-cloudy-night" width="64" height="64">
  61. </canvas>
  62. <canvas id="cloudy" width="64" height="64">
  63. </canvas>
  64. <canvas id="rain" width="64" height="64">
  65. </canvas>
  66. <canvas id="sleet" width="64" height="64">
  67. </canvas>
  68. <canvas id="snow" width="64" height="64">
  69. </canvas>
  70. <canvas id="wind" width="64" height="64">
  71. </canvas>
  72. <canvas id="fog" width="64" height="64">
  73. </canvas>
  74. </figure>
  75. <p>They&rsquo;re easy to use, and pretty lightweight, so they
  76. shouldn&rsquo;t rain on your parade:</p>
  77. <pre>&lt;canvas id="icon1" width="128" height="128"&gt;&lt;/canvas&gt;
  78. &lt;canvas id="icon2" width="128" height="128"&gt;&lt;/canvas&gt;
  79. &lt;script&gt;
  80. var skycons = new Skycons({<span class="constant">"color"</span>: <span class="constant">"pink"</span>});
  81. <span class="comment">// on Android, a nasty hack is needed: {"resizeClear": true}</span>
  82. <span class="comment">// you can add a canvas by it's ID...</span>
  83. skycons.add(<span class="constant">"icon1"</span>, Skycons.PARTLY_CLOUDY_DAY);
  84. <span class="comment">// ...or by the canvas DOM element itself.</span>
  85. skycons.add(document.getElementById(<span class="constant">"icon2"</span>), Skycons.RAIN);
  86. <span class="comment">// if you're using the Forecast API, you can also supply
  87. // strings: "partly-cloudy-day" or "rain".</span>
  88. <span class="comment">// start animation!</span>
  89. skycons.play();
  90. <span class="comment">// you can also halt animation with skycons.pause()</span>
  91. <span class="comment">// want to change the icon? no problem:</span>
  92. skycons.set(<span class="constant">"icon1"</span>, Skycons.PARTLY_CLOUDY_NIGHT);
  93. <span class="comment">// want to remove one altogether? no problem:</span>
  94. skycons.remove(<span class="constant">"icon2"</span>);
  95. &lt;/script&gt;</pre>
  96. <p>Skycons were designed for <a href="http://forecast.io/">Forecast</a>
  97. by those wacky folks at <strong>The Dark Sky Company</strong>, and were
  98. heavily inspired by Adam Whitcroft&rsquo;s excellent
  99. <a href="http://adamwhitcroft.com/climacons/">Climacons</a>. The source
  100. code is available on
  101. <a href="http://github.com/darkskyapp/skycons">Github</a>, and has been
  102. <a href="http://creativecommons.org/publicdomain/zero/1.0/">released
  103. into the public domain</a>, so please do with it as you see fit!
  104. &#9825;</p>
  105. </article>
  106. <script src="skycons.js"></script>
  107. <script>
  108. var icons = new Skycons(),
  109. list = [
  110. "clear-day", "clear-night", "partly-cloudy-day",
  111. "partly-cloudy-night", "cloudy", "rain", "sleet", "snow", "wind",
  112. "fog"
  113. ],
  114. i;
  115. for(i = list.length; i--; )
  116. icons.set(list[i], list[i]);
  117. icons.play();
  118. </script>
  119. </body>
  120. </html>