skycons.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. (function(global) {
  2. "use strict";
  3. /* Set up a RequestAnimationFrame shim so we can animate efficiently FOR
  4. * GREAT JUSTICE. */
  5. var requestInterval, cancelInterval;
  6. (function() {
  7. var raf = global.requestAnimationFrame ||
  8. global.webkitRequestAnimationFrame ||
  9. global.mozRequestAnimationFrame ||
  10. global.oRequestAnimationFrame ||
  11. global.msRequestAnimationFrame ,
  12. caf = global.cancelAnimationFrame ||
  13. global.webkitCancelAnimationFrame ||
  14. global.mozCancelAnimationFrame ||
  15. global.oCancelAnimationFrame ||
  16. global.msCancelAnimationFrame ;
  17. if(raf && caf) {
  18. requestInterval = function(fn, delay) {
  19. var handle = {value: null};
  20. function loop() {
  21. handle.value = raf(loop);
  22. fn();
  23. }
  24. loop();
  25. return handle;
  26. };
  27. cancelInterval = function(handle) {
  28. caf(handle.value);
  29. };
  30. }
  31. else {
  32. requestInterval = setInterval;
  33. cancelInterval = clearInterval;
  34. }
  35. }());
  36. /* Define skycon things. */
  37. /* FIXME: I'm *really really* sorry that this code is so gross. Really, I am.
  38. * I'll try to clean it up eventually! Promise! */
  39. var KEYFRAME = 500,
  40. STROKE = 0.08,
  41. TAU = 2.0 * Math.PI,
  42. TWO_OVER_SQRT_2 = 2.0 / Math.sqrt(2);
  43. function circle(ctx, x, y, r) {
  44. ctx.beginPath();
  45. ctx.arc(x, y, r, 0, TAU, false);
  46. ctx.fill();
  47. }
  48. function line(ctx, ax, ay, bx, by) {
  49. ctx.beginPath();
  50. ctx.moveTo(ax, ay);
  51. ctx.lineTo(bx, by);
  52. ctx.stroke();
  53. }
  54. function puff(ctx, t, cx, cy, rx, ry, rmin, rmax) {
  55. var c = Math.cos(t * TAU),
  56. s = Math.sin(t * TAU);
  57. rmax -= rmin;
  58. circle(
  59. ctx,
  60. cx - s * rx,
  61. cy + c * ry + rmax * 0.5,
  62. rmin + (1 - c * 0.5) * rmax
  63. );
  64. }
  65. function puffs(ctx, t, cx, cy, rx, ry, rmin, rmax) {
  66. var i;
  67. for(i = 5; i--; )
  68. puff(ctx, t + i / 5, cx, cy, rx, ry, rmin, rmax);
  69. }
  70. function cloud(ctx, t, cx, cy, cw, s, color) {
  71. t /= 30000;
  72. var a = cw * 0.21,
  73. b = cw * 0.12,
  74. c = cw * 0.24,
  75. d = cw * 0.28;
  76. ctx.fillStyle = color;
  77. puffs(ctx, t, cx, cy, a, b, c, d);
  78. ctx.globalCompositeOperation = 'destination-out';
  79. puffs(ctx, t, cx, cy, a, b, c - s, d - s);
  80. ctx.globalCompositeOperation = 'source-over';
  81. }
  82. function sun(ctx, t, cx, cy, cw, s, color) {
  83. t /= 40000;
  84. var a = cw * 0.25 - s * 0.5,
  85. b = cw * 0.32 + s * 0.5,
  86. c = cw * 0.50 - s * 0.5,
  87. i, p, cos, sin;
  88. ctx.strokeStyle = color;
  89. ctx.lineWidth = s;
  90. ctx.lineCap = "round";
  91. ctx.lineJoin = "round";
  92. ctx.beginPath();
  93. ctx.arc(cx, cy, a, 0, TAU, false);
  94. ctx.stroke();
  95. for(i = 8; i--; ) {
  96. p = (t + i / 8) * TAU;
  97. cos = Math.cos(p);
  98. sin = Math.sin(p);
  99. line(ctx, cx + cos * b, cy + sin * b, cx + cos * c, cy + sin * c);
  100. }
  101. }
  102. function moon(ctx, t, cx, cy, cw, s, color) {
  103. t /= 15000;
  104. var a = cw * 0.29 - s * 0.5,
  105. b = cw * 0.05,
  106. c = Math.cos(t * TAU),
  107. p = c * TAU / -16;
  108. ctx.strokeStyle = color;
  109. ctx.lineWidth = s;
  110. ctx.lineCap = "round";
  111. ctx.lineJoin = "round";
  112. cx += c * b;
  113. ctx.beginPath();
  114. ctx.arc(cx, cy, a, p + TAU / 8, p + TAU * 7 / 8, false);
  115. ctx.arc(cx + Math.cos(p) * a * TWO_OVER_SQRT_2, cy + Math.sin(p) * a * TWO_OVER_SQRT_2, a, p + TAU * 5 / 8, p + TAU * 3 / 8, true);
  116. ctx.closePath();
  117. ctx.stroke();
  118. }
  119. function rain(ctx, t, cx, cy, cw, s, color) {
  120. t /= 1350;
  121. var a = cw * 0.16,
  122. b = TAU * 11 / 12,
  123. c = TAU * 7 / 12,
  124. i, p, x, y;
  125. ctx.fillStyle = color;
  126. for(i = 4; i--; ) {
  127. p = (t + i / 4) % 1;
  128. x = cx + ((i - 1.5) / 1.5) * (i === 1 || i === 2 ? -1 : 1) * a;
  129. y = cy + p * p * cw;
  130. ctx.beginPath();
  131. ctx.moveTo(x, y - s * 1.5);
  132. ctx.arc(x, y, s * 0.75, b, c, false);
  133. ctx.fill();
  134. }
  135. }
  136. function sleet(ctx, t, cx, cy, cw, s, color) {
  137. t /= 750;
  138. var a = cw * 0.1875,
  139. b = TAU * 11 / 12,
  140. c = TAU * 7 / 12,
  141. i, p, x, y;
  142. ctx.strokeStyle = color;
  143. ctx.lineWidth = s * 0.5;
  144. ctx.lineCap = "round";
  145. ctx.lineJoin = "round";
  146. for(i = 4; i--; ) {
  147. p = (t + i / 4) % 1;
  148. x = Math.floor(cx + ((i - 1.5) / 1.5) * (i === 1 || i === 2 ? -1 : 1) * a) + 0.5;
  149. y = cy + p * cw;
  150. line(ctx, x, y - s * 1.5, x, y + s * 1.5);
  151. }
  152. }
  153. function snow(ctx, t, cx, cy, cw, s, color) {
  154. t /= 3000;
  155. var a = cw * 0.16,
  156. b = s * 0.75,
  157. u = t * TAU * 0.7,
  158. ux = Math.cos(u) * b,
  159. uy = Math.sin(u) * b,
  160. v = u + TAU / 3,
  161. vx = Math.cos(v) * b,
  162. vy = Math.sin(v) * b,
  163. w = u + TAU * 2 / 3,
  164. wx = Math.cos(w) * b,
  165. wy = Math.sin(w) * b,
  166. i, p, x, y;
  167. ctx.strokeStyle = color;
  168. ctx.lineWidth = s * 0.5;
  169. ctx.lineCap = "round";
  170. ctx.lineJoin = "round";
  171. for(i = 4; i--; ) {
  172. p = (t + i / 4) % 1;
  173. x = cx + Math.sin((p + i / 4) * TAU) * a;
  174. y = cy + p * cw;
  175. line(ctx, x - ux, y - uy, x + ux, y + uy);
  176. line(ctx, x - vx, y - vy, x + vx, y + vy);
  177. line(ctx, x - wx, y - wy, x + wx, y + wy);
  178. }
  179. }
  180. function fogbank(ctx, t, cx, cy, cw, s, color) {
  181. t /= 30000;
  182. var a = cw * 0.21,
  183. b = cw * 0.06,
  184. c = cw * 0.21,
  185. d = cw * 0.28;
  186. ctx.fillStyle = color;
  187. puffs(ctx, t, cx, cy, a, b, c, d);
  188. ctx.globalCompositeOperation = 'destination-out';
  189. puffs(ctx, t, cx, cy, a, b, c - s, d - s);
  190. ctx.globalCompositeOperation = 'source-over';
  191. }
  192. /*
  193. var WIND_PATHS = [
  194. downsample(63, upsample(8, [
  195. -1.00, -0.28,
  196. -0.75, -0.18,
  197. -0.50, 0.12,
  198. -0.20, 0.12,
  199. -0.04, -0.04,
  200. -0.07, -0.18,
  201. -0.19, -0.18,
  202. -0.23, -0.05,
  203. -0.12, 0.11,
  204. 0.02, 0.16,
  205. 0.20, 0.15,
  206. 0.50, 0.07,
  207. 0.75, 0.18,
  208. 1.00, 0.28
  209. ])),
  210. downsample(31, upsample(16, [
  211. -1.00, -0.10,
  212. -0.75, 0.00,
  213. -0.50, 0.10,
  214. -0.25, 0.14,
  215. 0.00, 0.10,
  216. 0.25, 0.00,
  217. 0.50, -0.10,
  218. 0.75, -0.14,
  219. 1.00, -0.10
  220. ]))
  221. ];
  222. */
  223. var WIND_PATHS = [
  224. [
  225. -0.7500, -0.1800, -0.7219, -0.1527, -0.6971, -0.1225,
  226. -0.6739, -0.0910, -0.6516, -0.0588, -0.6298, -0.0262,
  227. -0.6083, 0.0065, -0.5868, 0.0396, -0.5643, 0.0731,
  228. -0.5372, 0.1041, -0.5033, 0.1259, -0.4662, 0.1406,
  229. -0.4275, 0.1493, -0.3881, 0.1530, -0.3487, 0.1526,
  230. -0.3095, 0.1488, -0.2708, 0.1421, -0.2319, 0.1342,
  231. -0.1943, 0.1217, -0.1600, 0.1025, -0.1290, 0.0785,
  232. -0.1012, 0.0509, -0.0764, 0.0206, -0.0547, -0.0120,
  233. -0.0378, -0.0472, -0.0324, -0.0857, -0.0389, -0.1241,
  234. -0.0546, -0.1599, -0.0814, -0.1876, -0.1193, -0.1964,
  235. -0.1582, -0.1935, -0.1931, -0.1769, -0.2157, -0.1453,
  236. -0.2290, -0.1085, -0.2327, -0.0697, -0.2240, -0.0317,
  237. -0.2064, 0.0033, -0.1853, 0.0362, -0.1613, 0.0672,
  238. -0.1350, 0.0961, -0.1051, 0.1213, -0.0706, 0.1397,
  239. -0.0332, 0.1512, 0.0053, 0.1580, 0.0442, 0.1624,
  240. 0.0833, 0.1636, 0.1224, 0.1615, 0.1613, 0.1565,
  241. 0.1999, 0.1500, 0.2378, 0.1402, 0.2749, 0.1279,
  242. 0.3118, 0.1147, 0.3487, 0.1015, 0.3858, 0.0892,
  243. 0.4236, 0.0787, 0.4621, 0.0715, 0.5012, 0.0702,
  244. 0.5398, 0.0766, 0.5768, 0.0890, 0.6123, 0.1055,
  245. 0.6466, 0.1244, 0.6805, 0.1440, 0.7147, 0.1630,
  246. 0.7500, 0.1800
  247. ],
  248. [
  249. -0.7500, 0.0000, -0.7033, 0.0195, -0.6569, 0.0399,
  250. -0.6104, 0.0600, -0.5634, 0.0789, -0.5155, 0.0954,
  251. -0.4667, 0.1089, -0.4174, 0.1206, -0.3676, 0.1299,
  252. -0.3174, 0.1365, -0.2669, 0.1398, -0.2162, 0.1391,
  253. -0.1658, 0.1347, -0.1157, 0.1271, -0.0661, 0.1169,
  254. -0.0170, 0.1046, 0.0316, 0.0903, 0.0791, 0.0728,
  255. 0.1259, 0.0534, 0.1723, 0.0331, 0.2188, 0.0129,
  256. 0.2656, -0.0064, 0.3122, -0.0263, 0.3586, -0.0466,
  257. 0.4052, -0.0665, 0.4525, -0.0847, 0.5007, -0.1002,
  258. 0.5497, -0.1130, 0.5991, -0.1240, 0.6491, -0.1325,
  259. 0.6994, -0.1380, 0.7500, -0.1400
  260. ]
  261. ],
  262. WIND_OFFSETS = [
  263. {start: 0.36, end: 0.11},
  264. {start: 0.56, end: 0.16}
  265. ];
  266. function leaf(ctx, t, x, y, cw, s, color) {
  267. var a = cw / 8,
  268. b = a / 3,
  269. c = 2 * b,
  270. d = (t % 1) * TAU,
  271. e = Math.cos(d),
  272. f = Math.sin(d);
  273. ctx.fillStyle = color;
  274. ctx.strokeStyle = color;
  275. ctx.lineWidth = s;
  276. ctx.lineCap = "round";
  277. ctx.lineJoin = "round";
  278. ctx.beginPath();
  279. ctx.arc(x , y , a, d , d + Math.PI, false);
  280. ctx.arc(x - b * e, y - b * f, c, d + Math.PI, d , false);
  281. ctx.arc(x + c * e, y + c * f, b, d + Math.PI, d , true );
  282. ctx.globalCompositeOperation = 'destination-out';
  283. ctx.fill();
  284. ctx.globalCompositeOperation = 'source-over';
  285. ctx.stroke();
  286. }
  287. function swoosh(ctx, t, cx, cy, cw, s, index, total, color) {
  288. t /= 2500;
  289. var path = WIND_PATHS[index],
  290. a = (t + index - WIND_OFFSETS[index].start) % total,
  291. c = (t + index - WIND_OFFSETS[index].end ) % total,
  292. e = (t + index ) % total,
  293. b, d, f, i;
  294. ctx.strokeStyle = color;
  295. ctx.lineWidth = s;
  296. ctx.lineCap = "round";
  297. ctx.lineJoin = "round";
  298. if(a < 1) {
  299. ctx.beginPath();
  300. a *= path.length / 2 - 1;
  301. b = Math.floor(a);
  302. a -= b;
  303. b *= 2;
  304. b += 2;
  305. ctx.moveTo(
  306. cx + (path[b - 2] * (1 - a) + path[b ] * a) * cw,
  307. cy + (path[b - 1] * (1 - a) + path[b + 1] * a) * cw
  308. );
  309. if(c < 1) {
  310. c *= path.length / 2 - 1;
  311. d = Math.floor(c);
  312. c -= d;
  313. d *= 2;
  314. d += 2;
  315. for(i = b; i !== d; i += 2)
  316. ctx.lineTo(cx + path[i] * cw, cy + path[i + 1] * cw);
  317. ctx.lineTo(
  318. cx + (path[d - 2] * (1 - c) + path[d ] * c) * cw,
  319. cy + (path[d - 1] * (1 - c) + path[d + 1] * c) * cw
  320. );
  321. }
  322. else
  323. for(i = b; i !== path.length; i += 2)
  324. ctx.lineTo(cx + path[i] * cw, cy + path[i + 1] * cw);
  325. ctx.stroke();
  326. }
  327. else if(c < 1) {
  328. ctx.beginPath();
  329. c *= path.length / 2 - 1;
  330. d = Math.floor(c);
  331. c -= d;
  332. d *= 2;
  333. d += 2;
  334. ctx.moveTo(cx + path[0] * cw, cy + path[1] * cw);
  335. for(i = 2; i !== d; i += 2)
  336. ctx.lineTo(cx + path[i] * cw, cy + path[i + 1] * cw);
  337. ctx.lineTo(
  338. cx + (path[d - 2] * (1 - c) + path[d ] * c) * cw,
  339. cy + (path[d - 1] * (1 - c) + path[d + 1] * c) * cw
  340. );
  341. ctx.stroke();
  342. }
  343. if(e < 1) {
  344. e *= path.length / 2 - 1;
  345. f = Math.floor(e);
  346. e -= f;
  347. f *= 2;
  348. f += 2;
  349. leaf(
  350. ctx,
  351. t,
  352. cx + (path[f - 2] * (1 - e) + path[f ] * e) * cw,
  353. cy + (path[f - 1] * (1 - e) + path[f + 1] * e) * cw,
  354. cw,
  355. s,
  356. color
  357. );
  358. }
  359. }
  360. var Skycons = function(opts) {
  361. this.list = [];
  362. this.interval = null;
  363. this.color = opts && opts.color ? opts.color : "black";
  364. this.resizeClear = !!(opts && opts.resizeClear);
  365. };
  366. Skycons.CLEAR_DAY = function(ctx, t, color) {
  367. var w = ctx.canvas.width,
  368. h = ctx.canvas.height,
  369. s = Math.min(w, h);
  370. sun(ctx, t, w * 0.5, h * 0.5, s, s * STROKE, color);
  371. };
  372. Skycons.CLEAR_NIGHT = function(ctx, t, color) {
  373. var w = ctx.canvas.width,
  374. h = ctx.canvas.height,
  375. s = Math.min(w, h);
  376. moon(ctx, t, w * 0.5, h * 0.5, s, s * STROKE, color);
  377. };
  378. Skycons.PARTLY_CLOUDY_DAY = function(ctx, t, color) {
  379. var w = ctx.canvas.width,
  380. h = ctx.canvas.height,
  381. s = Math.min(w, h);
  382. sun(ctx, t, w * 0.625, h * 0.375, s * 0.75, s * STROKE, color);
  383. cloud(ctx, t, w * 0.375, h * 0.625, s * 0.75, s * STROKE, color);
  384. };
  385. Skycons.PARTLY_CLOUDY_NIGHT = function(ctx, t, color) {
  386. var w = ctx.canvas.width,
  387. h = ctx.canvas.height,
  388. s = Math.min(w, h);
  389. moon(ctx, t, w * 0.667, h * 0.375, s * 0.75, s * STROKE, color);
  390. cloud(ctx, t, w * 0.375, h * 0.625, s * 0.75, s * STROKE, color);
  391. };
  392. Skycons.CLOUDY = function(ctx, t, color) {
  393. var w = ctx.canvas.width,
  394. h = ctx.canvas.height,
  395. s = Math.min(w, h);
  396. cloud(ctx, t, w * 0.5, h * 0.5, s, s * STROKE, color);
  397. };
  398. Skycons.RAIN = function(ctx, t, color) {
  399. var w = ctx.canvas.width,
  400. h = ctx.canvas.height,
  401. s = Math.min(w, h);
  402. rain(ctx, t, w * 0.5, h * 0.37, s * 0.9, s * STROKE, color);
  403. cloud(ctx, t, w * 0.5, h * 0.37, s * 0.9, s * STROKE, color);
  404. };
  405. Skycons.SLEET = function(ctx, t, color) {
  406. var w = ctx.canvas.width,
  407. h = ctx.canvas.height,
  408. s = Math.min(w, h);
  409. sleet(ctx, t, w * 0.5, h * 0.37, s * 0.9, s * STROKE, color);
  410. cloud(ctx, t, w * 0.5, h * 0.37, s * 0.9, s * STROKE, color);
  411. };
  412. Skycons.SNOW = function(ctx, t, color) {
  413. var w = ctx.canvas.width,
  414. h = ctx.canvas.height,
  415. s = Math.min(w, h);
  416. snow(ctx, t, w * 0.5, h * 0.37, s * 0.9, s * STROKE, color);
  417. cloud(ctx, t, w * 0.5, h * 0.37, s * 0.9, s * STROKE, color);
  418. };
  419. Skycons.WIND = function(ctx, t, color) {
  420. var w = ctx.canvas.width,
  421. h = ctx.canvas.height,
  422. s = Math.min(w, h);
  423. swoosh(ctx, t, w * 0.5, h * 0.5, s, s * STROKE, 0, 2, color);
  424. swoosh(ctx, t, w * 0.5, h * 0.5, s, s * STROKE, 1, 2, color);
  425. };
  426. Skycons.FOG = function(ctx, t, color) {
  427. var w = ctx.canvas.width,
  428. h = ctx.canvas.height,
  429. s = Math.min(w, h),
  430. k = s * STROKE;
  431. fogbank(ctx, t, w * 0.5, h * 0.32, s * 0.75, k, color);
  432. t /= 5000;
  433. var a = Math.cos((t ) * TAU) * s * 0.02,
  434. b = Math.cos((t + 0.25) * TAU) * s * 0.02,
  435. c = Math.cos((t + 0.50) * TAU) * s * 0.02,
  436. d = Math.cos((t + 0.75) * TAU) * s * 0.02,
  437. n = h * 0.936,
  438. e = Math.floor(n - k * 0.5) + 0.5,
  439. f = Math.floor(n - k * 2.5) + 0.5;
  440. ctx.strokeStyle = color;
  441. ctx.lineWidth = k;
  442. ctx.lineCap = "round";
  443. ctx.lineJoin = "round";
  444. line(ctx, a + w * 0.2 + k * 0.5, e, b + w * 0.8 - k * 0.5, e);
  445. line(ctx, c + w * 0.2 + k * 0.5, f, d + w * 0.8 - k * 0.5, f);
  446. };
  447. Skycons.prototype = {
  448. _determineDrawingFunction: function(draw) {
  449. if(typeof draw === "string")
  450. draw = Skycons[draw.toUpperCase().replace(/-/g, "_")] || null;
  451. return draw;
  452. },
  453. add: function(el, draw) {
  454. var obj;
  455. if(typeof el === "string")
  456. el = document.getElementById(el);
  457. // Does nothing if canvas name doesn't exists
  458. if(el === null)
  459. return;
  460. draw = this._determineDrawingFunction(draw);
  461. // Does nothing if the draw function isn't actually a function
  462. if(typeof draw !== "function")
  463. return;
  464. obj = {
  465. element: el,
  466. context: el.getContext("2d"),
  467. drawing: draw
  468. };
  469. this.list.push(obj);
  470. this.draw(obj, KEYFRAME);
  471. },
  472. set: function(el, draw) {
  473. var i;
  474. if(typeof el === "string")
  475. el = document.getElementById(el);
  476. for(i = this.list.length; i--; )
  477. if(this.list[i].element === el) {
  478. this.list[i].drawing = this._determineDrawingFunction(draw);
  479. this.draw(this.list[i], KEYFRAME);
  480. return;
  481. }
  482. this.add(el, draw);
  483. },
  484. remove: function(el) {
  485. var i;
  486. if(typeof el === "string")
  487. el = document.getElementById(el);
  488. for(i = this.list.length; i--; )
  489. if(this.list[i].element === el) {
  490. this.list.splice(i, 1);
  491. return;
  492. }
  493. },
  494. draw: function(obj, time) {
  495. var canvas = obj.context.canvas;
  496. if(this.resizeClear)
  497. canvas.width = canvas.width;
  498. else
  499. obj.context.clearRect(0, 0, canvas.width, canvas.height);
  500. obj.drawing(obj.context, time, this.color);
  501. },
  502. play: function() {
  503. var self = this;
  504. this.pause();
  505. this.interval = requestInterval(function() {
  506. var now = Date.now(),
  507. i;
  508. for(i = self.list.length; i--; )
  509. self.draw(self.list[i], now);
  510. }, 1000 / 60);
  511. },
  512. pause: function() {
  513. var i;
  514. if(this.interval) {
  515. cancelInterval(this.interval);
  516. this.interval = null;
  517. }
  518. }
  519. };
  520. global.Skycons = Skycons;
  521. }(this));