Facebook
From j e n Strike, 5 Years ago, written in HTML5.
Embed
Download Paste or View Raw
Hits: 180
  1. <br />
  2. <br />
  3. <br />
  4. <br />
  5. <br />
  6. <h3>&nbsp;</h3>
  7. <h3 id="h3">&nbsp;</h3>
  8. </div>
  9. </div>
  10. <canvas id="canvas"></canvas> <script>
  11. var Stats=function(){var e=Date.now(),t=e,i=0,n=1/0,r=0,s=0,o=1/0,a=0,l=0,h=0,c=document.createElement("div");c.id="stats",c.addEventListener("mousedown",function(e){e.preventDefault(),v(++h%2)},!1),c.style.cssText="width:80px;opacity:0.9;cursor:pointer";var u=document.createElement("div");u.id="fps",u.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#002",c.appendChild(u);var d=document.createElement("div");d.id="fpsText",d.style.cssText="color:#0ff;font-family:Comic Sans MS;font-size:9px;font-weight:bold;line-height:15px",d.innerHTML="FPS",u.appendChild(d);var p=document.createElement("div");for(p.id="fpsGraph",p.style.cssText="position:relative;width:74px;height:30px;background-color:#0ff",u.appendChild(p);74>p.children.length;){var f=document.createElement("span");f.style.cssText="width:1px;height:30px;float:left;background-color:#113",p.appendChild(f)}var m=document.createElement("div");m.id="ms",m.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#020;display:none",c.appendChild(m);var g=document.createElement("div");g.id="msText",g.style.cssText="color:#0f0;font-family:Comic Sans MS;font-size:9px;font-weight:bold;line-height:15px",g.innerHTML="MS",m.appendChild(g);var y=document.createElement("div");for(y.id="msGraph",y.style.cssText="position:relative;width:74px;height:30px;background-color:#0f0",m.appendChild(y);74>y.children.length;){var f=document.createElement("span");f.style.cssText="width:1px;height:30px;float:left;background-color:#131",y.appendChild(f)}var v=function(e){switch(h=e){case 0:u.style.display="block",m.style.display="none";break;case 1:u.style.display="none",m.style.display="block"}},b=function(e,t){var i=e.appendChild(e.firstChild);i.style.height=t+"px"};return{REVISION:11,domElement:c,setMode:v,begin:function(){e=Date.now()},end:function(){var h=Date.now();return i=h-e,n=Math.min(n,i),r=Math.max(r,i),g.textContent=i+" MS ("+n+"-"+r+")",b(y,Math.min(30,30-30*(i/200))),l++,h>t+1e3&&(s=Math.round(1e3*l/(h-t)),o=Math.min(o,s),a=Math.max(a,s),d.textContent=s+" FPS ("+o+"-"+a+")",b(p,Math.min(30,30-30*(s/100))),t=h,l=0),h},update:function(){e=this.end()}}};
  12. ;(function(window) {
  13. var ctx,
  14. hue,
  15. logo,
  16. form,
  17. buffer,
  18. target = {},
  19. tendrils = [],
  20. settings = {};
  21. settings.debug = true;
  22. settings.friction = 0.5;
  23. settings.trails = 20;
  24. settings.size = 50;
  25. settings.dampening = 0.25;
  26. settings.tension = 0.98;
  27. Math.TWO_PI = Math.PI * 2;
  28. // ========================================================================================
  29. // Oscillator
  30. // ----------------------------------------------------------------------------------------
  31. function Oscillator(options) {
  32. this.init(options || {});
  33. }
  34. Oscillator.prototype = (function() {
  35. var value = 0;
  36. return {
  37. init: function(options) {
  38. this.phase = options.phase || 0;
  39. this.offset = options.offset || 0;
  40. this.frequency = options.frequency || 0.001;
  41. this.amplitude = options.amplitude || 1;
  42. },
  43. update: function() {
  44. this.phase += this.frequency;
  45. value = this.offset + Math.sin(this.phase) * this.amplitude;
  46. return value;
  47. },
  48. value: function() {
  49. return value;
  50. }
  51. };
  52. })();
  53. // ========================================================================================
  54. // Tendril
  55. // ----------------------------------------------------------------------------------------
  56. function Tendril(options) {
  57. this.init(options || {});
  58. }
  59. Tendril.prototype = (function() {
  60. function Node() {
  61. this.x = 0;
  62. this.y = 0;
  63. this.vy = 0;
  64. this.vx = 0;
  65. }
  66. return {
  67. init: function(options) {
  68. this.spring = options.spring + (Math.random() * 0.1) - 0.05;
  69. this.friction = settings.friction + (Math.random() * 0.01) - 0.005;
  70. this.nodes = [];
  71. for(var i = 0, node; i < settings.size; i++) {
  72. node = new Node();
  73. node.x = target.x;
  74. node.y = target.y;
  75. this.nodes.push(node);
  76. }
  77. },
  78. update: function() {
  79. var spring = this.spring,
  80. node = this.nodes[0];
  81. node.vx += (target.x - node.x) * spring;
  82. node.vy += (target.y - node.y) * spring;
  83. for(var prev, i = 0, n = this.nodes.length; i < n; i++) {
  84. node = this.nodes[i];
  85. if(i > 0) {
  86. prev = this.nodes[i - 1];
  87. node.vx += (prev.x - node.x) * spring;
  88. node.vy += (prev.y - node.y) * spring;
  89. node.vx += prev.vx * settings.dampening;
  90. node.vy += prev.vy * settings.dampening;
  91. }
  92. node.vx *= this.friction;
  93. node.vy *= this.friction;
  94. node.x += node.vx;
  95. node.y += node.vy;
  96. spring *= settings.tension;
  97. }
  98. },
  99. draw: function() {
  100. var x = this.nodes[0].x,
  101. y = this.nodes[0].y,
  102. a, b;
  103. ctx.beginPath();
  104. ctx.moveTo(x, y);
  105. for(var i = 1, n = this.nodes.length - 2; i < n; i++) {
  106. a = this.nodes[i];
  107. b = this.nodes[i + 1];
  108. x = (a.x + b.x) * 0.5;
  109. y = (a.y + b.y) * 0.5;
  110. ctx.quadraticCurveTo(a.x, a.y, x, y);
  111. }
  112. a = this.nodes[i];
  113. b = this.nodes[i + 1];
  114. ctx.quadraticCurveTo(a.x, a.y, b.x, b.y);
  115. ctx.stroke();
  116. ctx.closePath();
  117. }
  118. };
  119. })();
  120. // ----------------------------------------------------------------------------------------
  121. function init(event) {
  122. document.removeEventListener('mousemove', init);
  123. document.removeEventListener('touchstart', init);
  124. document.addEventListener('mousemove', mousemove);
  125. document.addEventListener('touchmove', mousemove);
  126. document.addEventListener('touchstart', touchstart);
  127. mousemove(event);
  128. reset();
  129. loop();
  130. }
  131. function reset() {
  132. tendrils = [];
  133. for(var i = 0; i < settings.trails; i++) {
  134. tendrils.push(new Tendril({
  135. spring: 0.45 + 0.025 * (i / settings.trails)
  136. }));
  137. }
  138. }
  139. function loop() {
  140. if(!ctx.running) return;
  141. ctx.globalCompositeOperation = 'source-over';
  142. ctx.fillStyle = 'rgba(8,5,16,0.4)';
  143. ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
  144. ctx.globalCompositeOperation = 'lighter';
  145. ctx.strokeStyle = 'hsla(' + Math.round(hue.update()) + ',90%,50%,0.25)';
  146. ctx.lineWidth = 1;
  147. if(ctx.frame % 60 == 0) {
  148. console.log(hue.update(), Math.round(hue.update()), hue.phase, hue.offset, hue.frequency, hue.amplitude);
  149. }
  150. for(var i = 0, tendril; i < settings.trails; i++) {
  151. tendril = tendrils[i];
  152. tendril.update();
  153. tendril.draw();
  154. }
  155. ctx.frame++;
  156. ctx.stats.update();
  157. requestAnimFrame(loop);
  158. }
  159. function resize() {
  160. ctx.canvas.width = window.innerWidth;
  161. ctx.canvas.height = window.innerHeight;
  162. }
  163. function start() {
  164. if(!ctx.running) {
  165. ctx.running = true;
  166. loop();
  167. }
  168. }
  169. function stop() {
  170. ctx.running = false;
  171. }
  172. function mousemove(event) {
  173. if(event.touches) {
  174. target.x = event.touches[0].pageX;
  175. target.y = event.touches[0].pageY;
  176. } else {
  177. target.x = event.clientX
  178. target.y = event.clientY;
  179. }
  180. event.preventDefault();
  181. }
  182. function touchstart(event) {
  183. if(event.touches.length == 1) {
  184. target.x = event.touches[0].pageX;
  185. target.y = event.touches[0].pageY;
  186. }
  187. }
  188. function keyup(event) {
  189. switch(event.keyCode) {
  190. case 32:
  191. save();
  192. break;
  193. default:
  194. // console.log(event.keyCode);
  195. }
  196. }
  197. function letters(id) {
  198. var el = document.getElementById(id),
  199. letters = el.innerHTML.replace('&amp;', '&').split(''),
  200. heading = '';
  201. for(var i = 0, n = letters.length, letter; i < n; i++) {
  202. letter = letters[i].replace('&', '&amp');
  203. heading += letter.trim() ? '<span class="letter-' + i + '">' + letter + '</span>' : '&nbsp;';
  204. }
  205. el.innerHTML = heading;
  206. setTimeout(function() {
  207. el.className = 'transition-in';
  208. }, (Math.random() * 500) + 500);
  209. }
  210. function save() {
  211. if(!buffer) {
  212. buffer = document.createElement('canvas');
  213. buffer.width = screen.availWidth;
  214. buffer.height = screen.availHeight;
  215. buffer.ctx = buffer.getContext('2d');
  216. form = document.createElement('form');
  217. form.method = 'post';
  218. form.input = document.createElement('input');
  219. form.input.type = 'hidden';
  220. form.input.name = 'data';
  221. form.appendChild(form.input);
  222. document.body.appendChild(form);
  223. }
  224. buffer.ctx.fillStyle = 'rgba(8,5,16)';
  225. buffer.ctx.fillRect(0, 0, buffer.width, buffer.height);
  226. buffer.ctx.drawImage(canvas,
  227. Math.round(buffer.width / 2 - canvas.width / 2),
  228. Math.round(buffer.height / 2 - canvas.height / 2)
  229. );
  230. buffer.ctx.drawImage(logo,
  231. Math.round(buffer.width / 2 - logo.width / 4),
  232. Math.round(buffer.height / 2 - logo.height / 4),
  233. logo.width / 2,
  234. logo.height / 2
  235. );
  236. window.open(buffer.toDataURL(), 'wallpaper', 'top=0,left=0,width=' + buffer.width + ',height=' + buffer.height);
  237. // form.input.value = buffer.toDataURL().substr(22);
  238. // form.submit();
  239. }
  240. window.requestAnimFrame = (function() {
  241. return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(fn) { window.setTimeout(fn, 1000 / 60) };
  242. })();
  243. window.onload = function() {
  244. ctx = document.getElementById('canvas').getContext('2d');
  245. ctx.stats = new Stats();
  246. ctx.running = true;
  247. ctx.frame = 1;
  248. logo = new Image();
  249. logo.src = 'http://labs.nikrowell.com/lightsandmotion/ultraviolet/images/logo.png';
  250. hue = new Oscillator({
  251. phase: Math.random() * Math.TWO_PI,
  252. amplitude: 85,
  253. frequency: 0.0015,
  254. offset: 285
  255. });
  256. letters('h1');
  257. letters('h2');
  258. document.addEventListener('mousemove', init);
  259. document.addEventListener('touchstart', init);
  260. document.body.addEventListener('orientationchange', resize);
  261. window.addEventListener('resize', resize);
  262. window.addEventListener('keyup', keyup);
  263. window.addEventListener('focus', start);
  264. window.addEventListener('blur', stop);
  265. resize();
  266. if(window.DEBUG) {
  267. var gui = new dat.GUI();
  268. // gui.add(settings, 'debug');
  269. settings.gui.add(settings, 'trails', 1, 30).onChange(reset);
  270. settings.gui.add(settings, 'size', 25, 75).onFinishChange(reset);
  271. settings.gui.add(settings, 'friction', 0.45, 0.55).onFinishChange(reset);
  272. settings.gui.add(settings, 'dampening', 0.01, 0.4).onFinishChange(reset);
  273. settings.gui.add(settings, 'tension', 0.95, 0.999).onFinishChange(reset);
  274. document.body.appendChild(ctx.stats.domElement);
  275. }
  276. };
  277. })(window);
  278. </script> <embed src="" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="1" height="0"></embed>  <script type="text/javascript">
  279. //form tags to omit in NS6+:
  280. var omitformtags=["input", "textarea", "select"]
  281. omitformtags=omitformtags.join("|")
  282. function disableselect(e){
  283. if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
  284. return false
  285. }
  286. function reEnable(){
  287. return true
  288. }
  289. if (typeof document.onselectstart!="undefined")
  290. document.onselectstart=new Function ("return false")
  291. else{
  292. document.onmousedown=disableselect
  293. document.onmouseup=reEnable
  294. }
  295. </script>  &nbsp; <script type="text/javascript">
  296. //form tags to omit in NS6+:
  297. var omitformtags=["input", "textarea", "select"]
  298. omitformtags=omitformtags.join("|")
  299. function disableselect(e){
  300. if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
  301. return false
  302. }
  303. function reEnable(){
  304. return true
  305. }
  306. if (typeof document.onselectstart!="undefined")
  307. document.onselectstart=new Function ("return false")
  308. else{
  309. document.onmousedown=disableselect
  310. document.onmouseup=reEnable
  311. }
  312. </script>   <script> //show title one by one
  313. var tit = document.title;var c = 0; function writetitle() {document.title = tit.substring(0,c);if(c==tit.length){c = 0;setTimeout("writetitle()", 2000)}else {c++;setTimeout("writetitle()",275)}}writetitle()</script> <audio loop="" autoplay="" controls="" hidden="">     <source src="http://dl.nex1downloadmusic.com/Arash%20And%20SnoopDogg%20OMG%5B128%5D%20Nex1downloadmusic.com.mp3" type="audio/mpeg"></source>    </audio>
  314. <iframe width="0%" height="0" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/267101609&amp;color=ff5500&amp;auto_play=true&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false"></iframe>
  315. <p>&nbsp;</p>