Guest User

Untitled

a guest
Oct 5th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.25 KB | None | 0 0
  1. ! function(t) {
  2. function e(t) {
  3. this.init(t || {})
  4. }
  5.  
  6. function n(t) {
  7. this.init(t || {})
  8. }
  9.  
  10. function i(t) {
  11. document.removeEventListener("mousemove", i), document.removeEventListener("touchstart", i), document.addEventListener("mousemove", d), document.addEventListener("touchmove", d), document.addEventListener("touchstart", u), d(t), a(), o()
  12. }
  13.  
  14. function a() {
  15. w = [];
  16. for (var t = 0; t < E.trails; t++) w.push(new n({
  17. spring: .45 + .025 * (t / E.trails)
  18. }))
  19. }
  20.  
  21. function o() {
  22. if (f.running) {
  23. f.globalCompositeOperation = "source-over", f.fillStyle = "rgba(8,5,16,0.4)", f.fillRect(0, 0, f.canvas.width, f.canvas.height), f.globalCompositeOperation = "lighter", f.strokeStyle = "hsla(" + Math.round(l.update()) + ",90%,50%,0.25)", f.lineWidth = 1, f.frame % 60 == 0 && console.log(l.update(), Math.round(l.update()), l.phase, l.offset, l.frequency, l.amplitude);
  24. for (var t, e = 0; e < E.trails; e++) t = w[e], t.update(), t.draw();
  25. f.frame++, f.stats.update(), requestAnimFrame(o)
  26. }
  27. }
  28.  
  29. function s() {
  30. f.canvas.width = t.innerWidth, f.canvas.height = t.innerHeight
  31. }
  32.  
  33. function r() {
  34. f.running || (f.running = !0, o())
  35. }
  36.  
  37. function h() {
  38. f.running = !1
  39. }
  40.  
  41. function d(t) {
  42. t.touches ? (x.x = t.touches[0].pageX, x.y = t.touches[0].pageY) : (x.x = t.clientX, x.y = t.clientY), t.preventDefault()
  43. }
  44.  
  45. function u(t) {
  46. 1 == t.touches.length && (x.x = t.touches[0].pageX, x.y = t.touches[0].pageY)
  47. }
  48.  
  49. function c(t) {
  50. switch (t.keyCode) {
  51. case 32:
  52. p()
  53. }
  54. }
  55.  
  56. function m(t) {
  57. for (var e, n = document.getElementById(t), i = n.innerHTML.replace("&amp;", "&").split(""), a = "", o = 0, s = i.length; s > o; o++) e = i[o].replace("&", "&amp"), a += e.trim() ? '<span class="letter-' + o + '">' + e + "</span>" : "&nbsp;";
  58. n.innerHTML = a, setTimeout(function() {
  59. n.className = "transition-in"
  60. }, 500 * Math.random() + 500)
  61. }
  62.  
  63. function p() {
  64. y || (y = document.createElement("canvas"), y.width = screen.availWidth, y.height = screen.availHeight, y.ctx = y.getContext("2d"), g = document.createElement("form"), g.method = "post", g.input = document.createElement("input"), g.input.type = "hidden", g.input.name = "data", g.appendChild(g.input), document.body.appendChild(g)), y.ctx.fillStyle = "rgba(8,5,16)", y.ctx.fillRect(0, 0, y.width, y.height), y.ctx.drawImage(canvas, Math.round(y.width / 2 - canvas.width / 2), Math.round(y.height / 2 - canvas.height / 2)), y.ctx.drawImage(v, Math.round(y.width / 2 - v.width / 4), Math.round(y.height / 2 - v.height / 4), v.width / 2, v.height / 2), t.open(y.toDataURL(), "wallpaper", "top=0,left=0,width=" + y.width + ",height=" + y.height)
  65. }
  66. var f, l, v, g, y, x = {},
  67. w = [],
  68. E = {};
  69. E.debug = !1, E.friction = .5, E.trails = 20, E.size = 50, E.dampening = .25, E.tension = .98, Math.TWO_PI = 2 * Math.PI, e.prototype = function() {
  70. var t = 0;
  71. return {
  72. init: function(t) {
  73. this.phase = t.phase || 0, this.offset = t.offset || 0, this.frequency = t.frequency || .001, this.amplitude = t.amplitude || 1
  74. },
  75. update: function() {
  76. return this.phase += this.frequency, t = this.offset + Math.sin(this.phase) * this.amplitude
  77. },
  78. value: function() {
  79. return t
  80. }
  81. }
  82. }(), n.prototype = function() {
  83. function t() {
  84. this.x = 0, this.y = 0, this.vy = 0, this.vx = 0
  85. }
  86. return {
  87. init: function(e) {
  88. this.spring = e.spring + .1 * Math.random() - .05, this.friction = E.friction + .01 * Math.random() - .005, this.nodes = [];
  89. for (var n, i = 0; i < E.size; i++) n = new t, n.x = x.x, n.y = x.y, this.nodes.push(n)
  90. },
  91. update: function() {
  92. var t = this.spring,
  93. e = this.nodes[0];
  94. e.vx += (x.x - e.x) * t, e.vy += (x.y - e.y) * t;
  95. for (var n, i = 0, a = this.nodes.length; a > i; i++) e = this.nodes[i], i > 0 && (n = this.nodes[i - 1], e.vx += (n.x - e.x) * t, e.vy += (n.y - e.y) * t, e.vx += n.vx * E.dampening, e.vy += n.vy * E.dampening), e.vx *= this.friction, e.vy *= this.friction, e.x += e.vx, e.y += e.vy, t *= E.tension
  96. },
  97. draw: function() {
  98. var t, e, n = this.nodes[0].x,
  99. i = this.nodes[0].y;
  100. f.beginPath(), f.moveTo(n, i);
  101. for (var a = 1, o = this.nodes.length - 2; o > a; a++) t = this.nodes[a], e = this.nodes[a + 1], n = .5 * (t.x + e.x), i = .5 * (t.y + e.y), f.quadraticCurveTo(t.x, t.y, n, i);
  102. t = this.nodes[a], e = this.nodes[a + 1], f.quadraticCurveTo(t.x, t.y, e.x, e.y), f.stroke(), f.closePath()
  103. }
  104. }
  105. }(), t.requestAnimFrame = function() {
  106. return t.requestAnimationFrame || t.webkitRequestAnimationFrame || t.mozRequestAnimationFrame || function(e) {
  107. t.setTimeout(e, 1e3 / 60)
  108. }
  109. }(), t.onload = function() {
  110. if (f = document.getElementById("canvas").getContext("2d"), f.stats = new Stats, f.running = !0, f.frame = 1, v = new Image, v.src = "images/logo.png", l = new e({
  111. phase: Math.random() * Math.TWO_PI,
  112. amplitude: 85,
  113. frequency: .0015,
  114. offset: 285
  115. }), m("h1"), m("h2"), document.addEventListener("mousemove", i), document.addEventListener("touchstart", i), document.body.addEventListener("orientationchange", s), t.addEventListener("resize", s), t.addEventListener("keyup", c), t.addEventListener("focus", r), t.addEventListener("blur", h), s(), t.DEBUG) {
  116. var n = new dat.GUI;
  117. n.add(E, "trails", 1, 30).onChange(a), n.add(E, "size", 25, 75).onFinishChange(a), n.add(E, "friction", .45, .55).onFinishChange(a), n.add(E, "dampening", .01, .4).onFinishChange(a), n.add(E, "tension", .95, .999).onFinishChange(a), document.body.appendChild(f.stats.domElement)
  118. }
  119. }
  120. }(window);
Advertisement
Add Comment
Please, Sign In to add comment