1/* ----------------------------------------------- 2/* Author : Vincent Garreau - vincentgarreau.com 3/* MIT license: http://opensource.org/licenses/MIT 4/* Demo / Generator : vincentgarreau.com/particles.js 5/* GitHub : github.com/VincentGarreau/particles.js 6/* How to use? : Check the GitHub README 7/* v2.0.0 8/* ----------------------------------------------- */ 9 10function hexToRgb(e) { 11 var a = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; 12 e = e.replace(a, function(e, a, t, i) { 13 return a + a + t + t + i + i 14 }); 15 var t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e); 16 return t ? { 17 r: parseInt(t[1], 16), 18 g: parseInt(t[2], 16), 19 b: parseInt(t[3], 16) 20 } : null 21} 22 23function clamp(e, a, t) { 24 return Math.min(Math.max(e, a), t) 25} 26 27function isInArray(e, a) { 28 return a.indexOf(e) > -1 29} 30var pJS = function(e, a) { 31 var t = document.querySelector("#" + e + " > .particles-js-canvas-el"); 32 this.pJS = { 33 canvas: { 34 el: t, 35 w: t.offsetWidth, 36 h: t.offsetHeight 37 }, 38 particles: { 39 number: { 40 value: 400, 41 density: { 42 enable: !0, 43 value_area: 800 44 } 45 }, 46 color: { 47 value: "#fff" 48 }, 49 shape: { 50 type: "circle", 51 stroke: { 52 width: 0, 53 color: "#ff0000" 54 }, 55 polygon: { 56 nb_sides: 5 57 }, 58 image: { 59 src: "", 60 width: 100, 61 height: 100 62 } 63 }, 64 opacity: { 65 value: 1, 66 random: !1, 67 anim: { 68 enable: !1, 69 speed: 2, 70 opacity_min: 0, 71 sync: !1 72 } 73 }, 74 size: { 75 value: 20, 76 random: !1, 77 anim: { 78 enable: !1, 79 speed: 20, 80 size_min: 0, 81 sync: !1 82 } 83 }, 84 line_linked: { 85 enable: !0, 86 distance: 100, 87 color: "#fff", 88 opacity: 1, 89 width: 1 90 }, 91 move: { 92 enable: !0, 93 speed: 2, 94 direction: "none", 95 random: !1, 96 straight: !1, 97 out_mode: "out", 98 bounce: !1, 99 attract: { 100 enable: !1, 101 rotateX: 3e3, 102 rotateY: 3e3 103 } 104 }, 105 array: [] 106 }, 107 interactivity: { 108 detect_on: "canvas", 109 events: { 110 onhover: { 111 enable: !0, 112 mode: "grab" 113 }, 114 onclick: { 115 enable: !0, 116 mode: "push" 117 }, 118 resize: !0 119 }, 120 modes: { 121 grab: { 122 distance: 100, 123 line_linked: { 124 opacity: 1 125 } 126 }, 127 bubble: { 128 distance: 200, 129 size: 80, 130 duration: .4 131 }, 132 repulse: { 133 distance: 200, 134 duration: .4 135 }, 136 push: { 137 particles_nb: 4 138 }, 139 remove: { 140 particles_nb: 2 141 } 142 }, 143 mouse: {} 144 }, 145 retina_detect: !1, 146 fn: { 147 interact: {}, 148 modes: {}, 149 vendors: {} 150 }, 151 tmp: {} 152 }; 153 var i = this.pJS; 154 a && Object.deepExtend(i, a), i.tmp.obj = { 155 size_value: i.particles.size.value, 156 size_anim_speed: i.particles.size.anim.speed,
157 move_speed: i.particles.move.speed, 158 line_linked_distance: i.particles.line_linked.distance, 159 line_linked_width: i.particles.line_linked.width, 160 mode_grab_distance: i.interactivity.modes.grab.distance, 161 mode_bubble_distance: i.interactivity.modes.bubble.distance, 162 mode_bubble_size: i.interactivity.modes.bubble.size, 163 mode_repulse_distance: i.interactivity.modes.repulse.distance 164 }, i.fn.retinaInit = function() { 165 i.retina_detect && window.devicePixelRatio > 1 ? (i.canvas.pxratio = window.devicePixelRatio, i.tmp.retina = !0) : (i.canvas.pxratio = 1, i.tmp.retina = !1), i.canvas.w = i.canvas.el.offsetWidth * i.canvas.pxratio, i.canvas.h = i.canvas.el.offsetHeight * i.canvas.pxratio, i.particles.size.value = i.tmp.obj.size_value * i.canvas.pxratio, i.particles.size.anim.speed = i.tmp.obj.size_anim_speed * i.canvas.pxratio, i.particles.move.speed = i.tmp.obj.move_speed * i.canvas.pxratio, i.particles.line_linked.distance = i.tmp.obj.line_linked_distance * i.canvas.pxratio, i.interactivity.modes.grab.distance = i.tmp.obj.mode_grab_distance * i.canvas.pxratio, i.interactivity.modes.bubble.distance = i.tmp.obj.mode_bubble_distance * i.canvas.pxratio, i.particles.line_linked.width = i.tmp.obj.line_linked_width * i.canvas.pxratio, i.interactivity.modes.bubble.size = i.tmp.obj.mode_bubble_size * i.canvas.pxratio, i.interactivity.modes.repulse.distance = i.tmp.obj.mode_repulse_distance * i.canvas.pxratio 166 }, i.fn.canvasInit = function() { 167 i.canvas.ctx = i.canvas.el.getContext("2d") 168 }, i.fn.canvasSize = function() { 169 i.canvas.el.width = i.canvas.w, i.canvas.el.height = i.canvas.h, i && i.interactivity.events.resize && window.addEventListener("resize", function() { 170 i.canvas.w = i.canvas.el.offsetWidth, i.canvas.h = i.canvas.el.offsetHeight, i.tmp.retina && (i.canvas.w *= i.canvas.pxratio, i.canvas.h *= i.canvas.pxratio), i.canvas.el.width = i.canvas.w, i.canvas.el.height = i.canvas.h, i.particles.move.enable || (i.fn.particlesEmpty(), i.fn.particlesCreate(), i.fn.particlesDraw(), i.fn.vendors.densityAutoParticles()), i.fn.vendors.densityAutoParticles() 171 }) 172 }, i.fn.canvasPaint = function() { 173 i.canvas.ctx.fillRect(0, 0, i.canvas.w, i.canvas.h) 174 }, i.fn.canvasClear = function() { 175 i.canvas.ctx.clearRect(0, 0, i.canvas.w, i.canvas.h) 176 }, i.fn.particle = function(e, a, t) { 177 if (this.radius = (i.particles.size.random ? Math.random() : 1) * i.particles.size.value, i.particles.size.anim.enable && (this.size_status = !1, this.vs = i.particles.size.anim.speed / 100, i.particles.size.anim.sync || (this.vs = this.vs * Math.random())), this.x = t ? t.x : Math.random() * i.canvas.w, this.y = t ? t.y : Math.random() * i.canvas.h, this.x > i.canvas.w - 2 * this.radius ? this.x = this.x - this.radius : this.x < 2 * this.radius && (this.x = this.x + this.radius), this.y > i.canvas.h - 2 * this.radius ? this.y = this.y - this.radius : this.y < 2 * this.radius && (this.y = this.y + this.radius), i.particles.move.bounce && i.fn.vendors.checkOverlap(this, t), this.color = {}, "object" == typeof e.value) 178 if (e.value instanceof Array) { 179 var s = e.value[Math.floor(Math.random() * i.particles.color.value.length)]; 180 this.color.rgb = hexToRgb(s) 181 } else void 0 != e.value.r && void 0 != e.value.g && void 0 != e.value.b && (this.color.rgb = { 182 r: e.value.r, 183 g: e.value.g, 184 b: e.value.b 185 }), void 0 != e.value.h && void 0 != e.value.s && void 0 != e.value.l && (this.color.hsl = { 186 h: e.value.h, 187 s: e.value.s, 188 l: e.value.l 189 }); 190 else "random" == e.value ? this.color.rgb = { 191 r: Math.floor(256 * Math.random()) + 0, 192 g: Math.floor(256 * Math.random()) + 0, 193 b: Math.floor(256 * Math.random()) + 0 194 } : "string" == typeof e.value && (this.color = e, this.color.rgb = hexToRgb(this.color.value)); 195 this.opacity = (i.particles.opacity.random ? Math.random() : 1) * i.particles.opacity.value, i.particles.opacity.anim.enable && (this.opacity_status = !1, this.vo = i.particles.opacity.anim.speed / 100, i.particles.opacity.anim.sync || (this.vo = this.vo * Math.random())); 196 var n = {}; 197 switch (i.particles.move.direction) { 198 case "top": 199 n = { 200 x: 0, 201 y: -1 202 }; 203 break; 204 case "top-right": 205 n = { 206 x: .5, 207 y: -.5 208 }; 209 break; 210 case "right": 211 n = { 212 x: 1, 213 y: -0 214 }; 215 break; 216 case "bottom-right": 217 n = { 218 x: .5, 219 y: .5 220 }; 221 break; 222 case "bottom": 223 n = { 224 x: 0, 225 y: 1 226 }; 227 break; 228 case "bottom-left": 229 n = { 230 x: -.5, 231 y: 1 232 }; 233 break;
234 case "left": 235 n = { 236 x: -1, 237 y: 0 238 }; 239 break; 240 case "top-left": 241 n = { 242 x: -.5, 243 y: -.5 244 }; 245 break; 246 default: 247 n = { 248 x: 0, 249 y: 0 250 } 251 } 252 i.particles.move.straight ? (this.vx = n.x, this.vy = n.y, i.particles.move.random && (this.vx = this.vx * Math.random(), this.vy = this.vy * Math.random())) : (this.vx = n.x + Math.random() - .5, this.vy = n.y + Math.random() - .5), this.vx_i = this.vx, this.vy_i = this.vy; 253 var r = i.particles.shape.type; 254 if ("object" == typeof r) { 255 if (r instanceof Array) { 256 var c = r[Math.floor(Math.random() * r.length)]; 257 this.shape = c 258 } 259 } else this.shape = r; 260 if ("image" == this.shape) { 261 var o = i.particles.shape; 262 this.img = { 263 src: o.image.src, 264 ratio: o.image.width / o.image.height 265 }, this.img.ratio || (this.img.ratio = 1), "svg" == i.tmp.img_type && void 0 != i.tmp.source_svg && (i.fn.vendors.createSvgImg(this), i.tmp.pushing && (this.img.loaded = !1)) 266 } 267 }, i.fn.particle.prototype.draw = function() { 268 function e() { 269 i.canvas.ctx.drawImage(r, a.x - t, a.y - t, 2 * t, 2 * t / a.img.ratio) 270 } 271 var a = this; 272 if (void 0 != a.radius_bubble) var t = a.radius_bubble; 273 else var t = a.radius; 274 if (void 0 != a.opacity_bubble) var s = a.opacity_bubble; 275 else var s = a.opacity; 276 if (a.color.rgb) var n = "rgba(" + a.color.rgb.r + "," + a.color.rgb.g + "," + a.color.rgb.b + "," + s + ")"; 277 else var n = "hsla(" + a.color.hsl.h + "," + a.color.hsl.s + "%," + a.color.hsl.l + "%," + s + ")"; 278 switch (i.canvas.ctx.fillStyle = n, i.canvas.ctx.beginPath(), a.shape) { 279 case "circle": 280 i.canvas.ctx.arc(a.x, a.y, t, 0, 2 * Math.PI, !1); 281 break; 282 case "edge": 283 i.canvas.ctx.rect(a.x - t, a.y - t, 2 * t, 2 * t); 284 break; 285 case "triangle": 286 i.fn.vendors.drawShape(i.canvas.ctx, a.x - t, a.y + t / 1.66, 2 * t, 3, 2); 287 break; 288 case "polygon": 289 i.fn.vendors.drawShape(i.canvas.ctx, a.x - t / (i.particles.shape.polygon.nb_sides / 3.5), a.y - t / .76, 2.66 * t / (i.particles.shape.polygon.nb_sides / 3), i.particles.shape.polygon.nb_sides, 1); 290 break; 291 case "star": 292 i.fn.vendors.drawShape(i.canvas.ctx, a.x - 2 * t / (i.particles.shape.polygon.nb_sides / 4), a.y - t / 1.52, 2 * t * 2.66 / (i.particles.shape.polygon.nb_sides / 3), i.particles.shape.polygon.nb_sides, 2); 293 break; 294 case "image": 295 if ("svg" == i.tmp.img_type) var r = a.img.obj; 296 else var r = i.tmp.img_obj; 297 r && e() 298 } 299 i.canvas.ctx.closePath(), i.particles.shape.stroke.width > 0 && (i.canvas.ctx.strokeStyle = i.particles.shape.stroke.color, i.canvas.ctx.lineWidth = i.particles.shape.stroke.width, i.canvas.ctx.stroke()), i.canvas.ctx.fill() 300 }, i.fn.particlesCreate = function() { 301 for (var e = 0; e < i.particles.number.value; e++) i.particles.array.push(new i.fn.particle(i.particles.color, i.particles.opacity.value)) 302 }, i.fn.particlesUpdate = function() { 303 for (var e = 0; e < i.particles.array.length; e++) { 304 var a = i.particles.array[e]; 305 if (i.particles.move.enable) { 306 var t = i.particles.move.speed / 2; 307 a.x += a.vx * t, a.y += a.vy * t 308 } 309 if (i.particles.opacity.anim.enable && (1 == a.opacity_status ? (a.opacity >= i.particles.opacity.value && (a.opacity_status = !1), a.opacity += a.vo) : (a.opacity <= i.particles.opacity.anim.opacity_min && (a.opacity_status = !0), a.opacity -= a.vo), a.opacity < 0 && (a.opacity = 0)), i.particles.size.anim.enable && (1 == a.size_status ? (a.radius >= i.particles.size.value && (a.size_status = !1), a.radius += a.vs) : (a.radius <= i.particles.size.anim.size_min && (a.size_status = !0), a.radius -= a.vs), a.radius < 0 && (a.radius = 0)), "bounce" ==
309i.particles.move.out_mode) var s = { 310 x_left: a.radius, 311 x_right: i.canvas.w, 312 y_top: a.radius, 313 y_bottom: i.canvas.h 314 }; 315 else var s = { 316 x_left: -a.radius, 317 x_right: i.canvas.w + a.radius, 318 y_top: -a.radius, 319 y_bottom: i.canvas.h + a.radius 320 }; 321 switch (a.x - a.radius > i.canvas.w ? (a.x = s.x_left, a.y = Math.random() * i.canvas.h) : a.x + a.radius < 0 && (a.x = s.x_right, a.y = Math.random() * i.canvas.h), a.y - a.radius > i.canvas.h ? (a.y = s.y_top, a.x = Math.random() * i.canvas.w) : a.y + a.radius < 0 && (a.y = s.y_bottom, a.x = Math.random() * i.canvas.w), i.particles.move.out_mode) { 322 case "bounce": 323 a.x + a.radius > i.canvas.w ? a.vx = -a.vx : a.x - a.radius < 0 && (a.vx = -a.vx), a.y + a.radius > i.canvas.h ? a.vy = -a.vy : a.y - a.radius < 0 && (a.vy = -a.vy) 324 } 325 if (isInArray("grab", i.interactivity.events.onhover.mode) && i.fn.modes.grabParticle(a), (isInArray("bubble", i.interactivity.events.onhover.mode) || isInArray("bubble", i.interactivity.events.onclick.mode)) && i.fn.modes.bubbleParticle(a), (isInArray("repulse", i.interactivity.events.onhover.mode) || isInArray("repulse", i.interactivity.events.onclick.mode)) && i.fn.modes.repulseParticle(a), i.particles.line_linked.enable || i.particles.move.attract.enable) 326 for (var n = e + 1; n < i.particles.array.length; n++) { 327 var r = i.particles.array[n]; 328 i.particles.line_linked.enable && i.fn.interact.linkParticles(a, r), i.particles.move.attract.enable && i.fn.interact.attractParticles(a, r), i.particles.move.bounce && i.fn.interact.bounceParticles(a, r) 329 } 330 } 331 }, i.fn.particlesDraw = function() { 332 i.canvas.ctx.clearRect(0, 0, i.canvas.w, i.canvas.h), i.fn.particlesUpdate(); 333 for (var e = 0; e < i.particles.array.length; e++) { 334 var a = i.particles.array[e]; 335 a.draw() 336 } 337 }, i.fn.particlesEmpty = function() { 338 i.particles.array = [] 339 }, i.fn.particlesRefresh = function() { 340 cancelRequestAnimFrame(i.fn.checkAnimFrame), cancelRequestAnimFrame(i.fn.drawAnimFrame), i.tmp.source_svg = void 0, i.tmp.img_obj = void 0, i.tmp.count_svg = 0, i.fn.particlesEmpty(), i.fn.canvasClear(), i.fn.vendors.start() 341 }, i.fn.interact.linkParticles = function(e, a) { 342 var t = e.x - a.x, 343 s = e.y - a.y, 344 n = Math.sqrt(t * t + s * s); 345 if (n <= i.particles.line_linked.distance) { 346 var r = i.particles.line_linked.opacity - n / (1 / i.particles.line_linked.opacity) / i.particles.line_linked.distance; 347 if (r > 0) { 348 var c = i.particles.line_linked.color_rgb_line; 349 i.canvas.ctx.strokeStyle = "rgba(" + c.r + "," + c.g + "," + c.b + "," + r + ")", i.canvas.ctx.lineWidth = i.particles.line_linked.width, i.canvas.ctx.beginPath(), i.canvas.ctx.moveTo(e.x, e.y), i.canvas.ctx.lineTo(a.x, a.y), i.canvas.ctx.stroke(), i.canvas.ctx.closePath() 350 } 351 } 352 }, i.fn.interact.attractParticles = function(e, a) { 353 var t = e.x - a.x, 354 s = e.y - a.y, 355 n = Math.sqrt(t * t + s * s); 356 if (n <= i.particles.line_linked.distance) { 357 var r = t / (1e3 * i.particles.move.attract.rotateX), 358 c = s / (1e3 * i.particles.move.attract.rotateY); 359 e.vx -= r, e.vy -= c, a.vx += r, a.vy += c 360 } 361 }, i.fn.interact.bounceParticles = function(e, a) { 362 var t = e.x - a.x, 363 i = e.y - a.y, 364 s = Math.sqrt(t * t + i * i), 365 n = e.radius + a.radius; 366 n >= s && (e.vx = -e.vx, e.vy = -e.vy, a.vx = -a.vx, a.vy = -a.vy) 367 }, i.fn.modes.pushParticles = function(e, a) { 368 i.tmp.pushing = !0; 369 for (var t = 0; e > t; t++) i.particles.array.push(new i.fn.particle(i.particles.color, i.particles.opacity.value, { 370 x: a ? a.pos_x : Math.random() * i.canvas.w, 371 y: a ? a.pos_y : Math.random() * i.canvas.h 372 })), t == e - 1 && (i.particles.move.enable || i.fn.particlesDraw(), i.tmp.pushing = !1) 373 }, i.fn.modes.removeParticles = function(e) { 374 i.particles.array.splice(0, e), i.particles.move.enable || i.fn.particlesDraw() 375 }, i.fn.modes.bubbleParticle = function(e) { 376 function a() { 377 e.opacity_bubble = e.opacity, e.radius_bubble = e.radius 378 } 379 380 function t(a, t, s, n, c) { 381 if (a != t) 382 if (i.tmp.bubble_duration_end) { 383 if (void 0 != s) { 384 var o = n - p * (n - a) / i.interactivity.modes.bubble.duration, 385 l = a - o;
386 d = a + l, "size" == c && (e.radius_bubble = d), "opacity" == c && (e.opacity_bubble = d) 387 } 388 } else if (r <= i.interactivity.modes.bubble.distance) { 389 if (void 0 != s) var v = s; 390 else var v = n; 391 if (v != a) { 392 var d = n - p * (n - a) / i.interactivity.modes.bubble.duration; 393 "size" == c && (e.radius_bubble = d), "opacity" == c && (e.opacity_bubble = d) 394 } 395 } else "size" == c && (e.radius_bubble = void 0), "opacity" == c && (e.opacity_bubble = void 0) 396 } 397 if (i.interactivity.events.onhover.enable && isInArray("bubble", i.interactivity.events.onhover.mode)) { 398 var s = e.x - i.interactivity.mouse.pos_x, 399 n = e.y - i.interactivity.mouse.pos_y, 400 r = Math.sqrt(s * s + n * n), 401 c = 1 - r / i.interactivity.modes.bubble.distance; 402 if (r <= i.interactivity.modes.bubble.distance) { 403 if (c >= 0 && "mousemove" == i.interactivity.status) { 404 if (i.interactivity.modes.bubble.size != i.particles.size.value) 405 if (i.interactivity.modes.bubble.size > i.particles.size.value) { 406 var o = e.radius + i.interactivity.modes.bubble.size * c; 407 o >= 0 && (e.radius_bubble = o) 408 } else { 409 var l = e.radius - i.interactivity.modes.bubble.size, 410 o = e.radius - l * c; 411 o > 0 ? e.radius_bubble = o : e.radius_bubble = 0 412 } 413 if (i.interactivity.modes.bubble.opacity != i.particles.opacity.value) 414 if (i.interactivity.modes.bubble.opacity > i.particles.opacity.value) { 415 var v = i.interactivity.modes.bubble.opacity * c; 416 v > e.opacity && v <= i.interactivity.modes.bubble.opacity && (e.opacity_bubble = v) 417 } else { 418 var v = e.opacity - (i.particles.opacity.value - i.interactivity.modes.bubble.opacity) * c; 419 v < e.opacity && v >= i.interactivity.modes.bubble.opacity && (e.opacity_bubble = v) 420 } 421 } 422 } else a(); 423 "mouseleave" == i.interactivity.status && a() 424 } else if (i.interactivity.events.onclick.enable && isInArray("bubble", i.interactivity.events.onclick.mode)) { 425 if (i.tmp.bubble_clicking) { 426 var s = e.x - i.interactivity.mouse.click_pos_x, 427 n = e.y - i.interactivity.mouse.click_pos_y, 428 r = Math.sqrt(s * s + n * n), 429 p = ((new Date).getTime() - i.interactivity.mouse.click_time) / 1e3; 430 p > i.interactivity.modes.bubble.duration && (i.tmp.bubble_duration_end = !0), p > 2 * i.interactivity.modes.bubble.duration && (i.tmp.bubble_clicking = !1, i.tmp.bubble_duration_end = !1) 431 } 432 i.tmp.bubble_clicking && (t(i.interactivity.modes.bubble.size, i.particles.size.value, e.radius_bubble, e.radius, "size"), t(i.interactivity.modes.bubble.opacity, i.particles.opacity.value, e.opacity_bubble, e.opacity, "opacity")) 433 } 434 }, i.fn.modes.repulseParticle = function(e) { 435 function a() { 436 var a = Math.atan2(d, p); 437 if (e.vx = u * Math.cos(a), e.vy = u * Math.sin(a), "bounce" == i.particles.move.out_mode) { 438 var t = { 439 x: e.x + e.vx, 440 y: e.y + e.vy 441 }; 442 t.x + e.radius > i.canvas.w ? e.vx = -e.vx : t.x - e.radius < 0 && (e.vx = -e.vx), t.y + e.radius > i.canvas.h ? e.vy = -e.vy : t.y - e.radius < 0 && (e.vy = -e.vy) 443 } 444 } 445 if (i.interactivity.events.onhover.enable && isInArray("repulse", i.interactivity.events.onhover.mode) && "mousemove" == i.interactivity.status) { 446 var t = e.x - i.interactivity.mouse.pos_x, 447 s = e.y - i.interactivity.mouse.pos_y, 448 n = Math.sqrt(t * t + s * s), 449 r = { 450 x: t / n, 451 y: s / n 452 }, 453 c = i.interactivity.modes.repulse.distance, 454 o = 100, 455 l = clamp(1 / c * (-1 * Math.pow(n / c, 2) + 1) * c * o, 0, 50), 456 v = { 457 x: e.x + r.x * l, 458 y: e.y + r.y * l 459 };
460 "bounce" == i.particles.move.out_mode ? (v.x - e.radius > 0 && v.x + e.radius < i.canvas.w && (e.x = v.x), v.y - e.radius > 0 && v.y + e.radius < i.canvas.h && (e.y = v.y)) : (e.x = v.x, e.y = v.y) 461 } else if (i.interactivity.events.onclick.enable && isInArray("repulse", i.interactivity.events.onclick.mode)) 462 if (i.tmp.repulse_finish || (i.tmp.repulse_count++, i.tmp.repulse_count == i.particles.array.length && (i.tmp.repulse_finish = !0)), i.tmp.repulse_clicking) { 463 var c = Math.pow(i.interactivity.modes.repulse.distance / 6, 3), 464 p = i.interactivity.mouse.click_pos_x - e.x, 465 d = i.interactivity.mouse.click_pos_y - e.y, 466 m = p * p + d * d, 467 u = -c / m * 1; 468 c >= m && a() 469 } else 0 == i.tmp.repulse_clicking && (e.vx = e.vx_i, e.vy = e.vy_i) 470 }, i.fn.modes.grabParticle = function(e) { 471 if (i.interactivity.events.onhover.enable && "mousemove" == i.interactivity.status) { 472 var a = e.x - i.interactivity.mouse.pos_x, 473 t = e.y - i.interactivity.mouse.pos_y, 474 s = Math.sqrt(a * a + t * t); 475 if (s <= i.interactivity.modes.grab.distance) { 476 var n = i.interactivity.modes.grab.line_linked.opacity - s / (1 / i.interactivity.modes.grab.line_linked.opacity) / i.interactivity.modes.grab.distance; 477 if (n > 0) { 478 var r = i.particles.line_linked.color_rgb_line; 479 i.canvas.ctx.strokeStyle = "rgba(" + r.r + "," + r.g + "," + r.b + "," + n + ")", i.canvas.ctx.lineWidth = i.particles.line_linked.width, i.canvas.ctx.beginPath(), i.canvas.ctx.moveTo(e.x, e.y), i.canvas.ctx.lineTo(i.interactivity.mouse.pos_x, i.interactivity.mouse.pos_y), i.canvas.ctx.stroke(), i.canvas.ctx.closePath() 480 } 481 } 482 } 483 }, i.fn.vendors.eventsListeners = function() { 484 "window" == i.interactivity.detect_on ? i.interactivity.el = window : i.interactivity.el = i.canvas.el, (i.interactivity.events.onhover.enable || i.interactivity.events.onclick.enable) && (i.interactivity.el.addEventListener("mousemove", function(e) { 485 if (i.interactivity.el == window) var a = e.clientX, 486 t = e.clientY; 487 else var a = e.offsetX || e.clientX, 488 t = e.offsetY || e.clientY; 489 i.interactivity.mouse.pos_x = a, i.interactivity.mouse.pos_y = t, i.tmp.retina && (i.interactivity.mouse.pos_x *= i.canvas.pxratio, i.interactivity.mouse.pos_y *= i.canvas.pxratio), i.interactivity.status = "mousemove" 490 }), i.interactivity.el.addEventListener("mouseleave", function(e) { 491 i.interactivity.mouse.pos_x = null, i.interactivity.mouse.pos_y = null, i.interactivity.status = "mouseleave" 492 })), i.interactivity.events.onclick.enable && i.interactivity.el.addEventListener("click", function() { 493 if (i.interactivity.mouse.click_pos_x = i.interactivity.mouse.pos_x, i.interactivity.mouse.click_pos_y = i.interactivity.mouse.pos_y, i.interactivity.mouse.click_time = (new Date).getTime(), i.interactivity.events.onclick.enable) switch (i.interactivity.events.onclick.mode) { 494 case "push": 495 i.particles.move.enable ? i.fn.modes.pushParticles(i.interactivity.modes.push.particles_nb, i.interactivity.mouse) : 1 == i.interactivity.modes.push.particles_nb ? i.fn.modes.pushParticles(i.interactivity.modes.push.particles_nb, i.interactivity.mouse) : i.interactivity.modes.push.particles_nb > 1 && i.fn.modes.pushParticles(i.interactivity.modes.push.particles_nb); 496 break; 497 case "remove": 498 i.fn.modes.removeParticles(i.interactivity.modes.remove.particles_nb); 499 break; 500 case "bubble": 501 i.tmp.bubble_clicking = !0; 502 break; 503 case "repulse": 504 i.tmp.repulse_clicking = !0, i.tmp.repulse_count = 0, i.tmp.repulse_finish = !1, setTimeout(function() { 505 i.tmp.repulse_clicking = !1 506 }, 1e3 * i.interactivity.modes.repulse.duration) 507 } 508 }) 509 }, i.fn.vendors.densityAutoParticles = function() { 510 if (i.particles.number.density.enable) { 511 var e = i.canvas.el.width * i.canvas.el.height / 1e3; 512 i.tmp.retina && (e /= 2 * i.canvas.pxratio); 513 var a = e * i.particles.number.value / i.particles.number.density.value_area,
514 t = i.particles.array.length - a; 515 0 > t ? i.fn.modes.pushParticles(Math.abs(t)) : i.fn.modes.removeParticles(t) 516 } 517 }, i.fn.vendors.checkOverlap = function(e, a) { 518 for (var t = 0; t < i.particles.array.length; t++) { 519 var s = i.particles.array[t], 520 n = e.x - s.x, 521 r = e.y - s.y, 522 c = Math.sqrt(n * n + r * r); 523 c <= e.radius + s.radius && (e.x = a ? a.x : Math.random() * i.canvas.w, e.y = a ? a.y : Math.random() * i.canvas.h, i.fn.vendors.checkOverlap(e)) 524 } 525 }, i.fn.vendors.createSvgImg = function(e) { 526 var a = i.tmp.source_svg, 527 t = /#([0-9A-F]{3,6})/gi, 528 s = a.replace(t, function(a, t, i, s) { 529 if (e.color.rgb) var n = "rgba(" + e.color.rgb.r + "," + e.color.rgb.g + "," + e.color.rgb.b + "," + e.opacity + ")"; 530 else var n = "hsla(" + e.color.hsl.h + "," + e.color.hsl.s + "%," + e.color.hsl.l + "%," + e.opacity + ")"; 531 return n 532 }), 533 n = new Blob([s], { 534 type: "image/svg+xml;charset=utf-8" 535 }), 536 r = window.URL || window.webkitURL || window, 537 c = r.createObjectURL(n), 538 o = new Image; 539 o.addEventListener("load", function() { 540 e.img.obj = o, e.img.loaded = !0, r.revokeObjectURL(c), i.tmp.count_svg++ 541 }), o.src = c 542 }, i.fn.vendors.destroypJS = function() { 543 cancelAnimationFrame(i.fn.drawAnimFrame), t.remove(), pJSDom = null 544 }, i.fn.vendors.drawShape = function(e, a, t, i, s, n) { 545 var r = s * n, 546 c = s / n, 547 o = 180 * (c - 2) / c, 548 l = Math.PI - Math.PI * o / 180; 549 e.save(), e.beginPath(), e.translate(a, t), e.moveTo(0, 0); 550 for (var v = 0; r > v; v++) e.lineTo(i, 0), e.translate(i, 0), e.rotate(l); 551 e.fill(), e.restore() 552 }, i.fn.vendors.exportImg = function() { 553 window.open(i.canvas.el.toDataURL("image/png"), "_blank") 554 }, i.fn.vendors.loadImg = function(e) { 555 if (i.tmp.img_error = void 0, "" != i.particles.shape.image.src) 556 if ("svg" == e) { 557 var a = new XMLHttpRequest; 558 a.open("GET", i.particles.shape.image.src), a.onreadystatechange = function(e) { 559 4 == a.readyState && (200 == a.status ? (i.tmp.source_svg = e.currentTarget.response, i.fn.vendors.checkBeforeDraw()) : (console.log("Error pJS - Image not found"), i.tmp.img_error = !0)) 560 }, a.send() 561 } else { 562 var t = new Image; 563 t.addEventListener("load", function() { 564 i.tmp.img_obj = t, i.fn.vendors.checkBeforeDraw() 565 }), t.src = i.particles.shape.image.src 566 } 567 else console.log("Error pJS - No image.src"), i.tmp.img_error = !0 568 }, i.fn.vendors.draw = function() { 569 "image" == i.particles.shape.type ? "svg" == i.tmp.img_type ? i.tmp.count_svg >= i.particles.number.value ? (i.fn.particlesDraw(), i.particles.move.enable ? i.fn.drawAnimFrame = requestAnimFrame(i.fn.vendors.draw) : cancelRequestAnimFrame(i.fn.drawAnimFrame)) : i.tmp.img_error || (i.fn.drawAnimFrame = requestAnimFrame(i.fn.vendors.draw)) : void 0 != i.tmp.img_obj ? (i.fn.particlesDraw(), i.particles.move.enable ? i.fn.drawAnimFrame = requestAnimFrame(i.fn.vendors.draw) : cancelRequestAnimFrame(i.fn.drawAnimFrame)) : i.tmp.img_error || (i.fn.drawAnimFrame = requestAnimFrame(i.fn.vendors.draw)) : (i.fn.particlesDraw(), i.particles.move.enable ? i.fn.drawAnimFrame = requestAnimFrame(i.fn.vendors.draw) : cancelRequestAnimFrame(i.fn.drawAnimFrame)) 570 }, i.fn.vendors.checkBeforeDraw = function() { 571 "image" == i.particles.shape.type ? "svg" == i.tmp.img_type && void 0 == i.tmp.source_svg ? i.tmp.checkAnimFrame = requestAnimFrame(check) : (cancelRequestAnimFrame(i.tmp.checkAnimFrame), i.tmp.img_error || (i.fn.vendors.init(), i.fn.vendors.draw())) : (i.fn.vendors.init(), i.fn.vendors.draw()) 572 }, i.fn.vendors.init = function() { 573 i.fn.retinaInit(), i.fn.canvasInit(), i.fn.canvasSize(), i.fn.canvasPaint(), i.fn.particlesCreate(), i.fn.vendors.densityAutoParticles(), i.particles.line_linked.color_rgb_line = hexToRgb(i.particles.line_linked.color) 574 }, i.fn.vendors.start = function() { 575 isInArray("image", i.particles.shape.type) ? (i.tmp.img_type = i.particles.shape.image.src.substr(i.particles.shape.image.src.length - 3), i.fn.vendors.loadImg(i.tmp.img_type)) : i.fn.vendors.checkBeforeDraw() 576 }, i.fn.vendors.eventsListeners(), i.fn.vendors.start() 577}; 578Object.deepExtend = function(e, a) { 579 for (var t in a) a[t] && a[t].constructor && a[t].constructor === Object ? (e[t] = e[t] || {}, arguments.callee(e[t], a[t])) : e[t] = a[t]; 580 return e 581}, window.requestAnimFrame = function() { 582 return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(e) { 583 window.setTimeout(e, 1e3 / 60) 584 } 585}(), window.cancelRequestAnimFrame = function() { 586 return window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || clearTimeout 587}(), window.pJSDom = [], window.particlesJS = function(e, a) { 588 "string" != typeof e && (a = e, e = "particles-js"), e || (e = "particles-js"); 589 var t = document.getElementById(e), 590 i = "particles-js-canvas-el", 591 s = t.getElementsByClassName(i); 592 if (s.length) 593 for (; s.length > 0;) t.removeChild(s[0]); 594 var n = document.createElement("canvas"); 595 n.className = i, n.style.width = "100%", n.style.height = "100%"; 596 var r = document.getElementById(e).appendChild(n); 597 null != r && pJSDom.push(new pJS(e, a)) 598}, window.particlesJS.load = function(e, a, t) { 599 var i = new XMLHttpRequest; 600 i.open("GET", a), i.onreadystatechange = function(a) { 601 if (4 == i.readyState) 602 if (200 == i.status) { 603 var s = JSON.parse(a.currentTarget.response); 604 window.particlesJS(e, s), t && t() 605 }
vendor: 3,076 bytes, lines 605-711
605 else console.log("Error pJS - XMLHttpRequest status: " + i.status), console.log("Error pJS - File config not found") 606 }, i.send() 607}; 608 609 610 611 612 613 614// stats.js - http://github.com/mrdoob/stats.js 615var Stats = function() { 616 function h(a) { 617 c.appendChild(a.dom); 618 return a 619 } 620 621 function k(a) { 622 for (var d = 0; d < c.children.length; d++) c.children[d].style.display = d === a ? "block" : "none"; 623 l = a 624 } 625 var l = 0, 626 c = document.createElement("div"); 627 c.style.cssText = "position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000"; 628 c.addEventListener("click", function(a) { 629 a.preventDefault(); 630 k(++l % c.children.length) 631 }, !1); 632 var g = (performance || Date).now(), 633 e = g, 634 a = 0, 635 r = h(new Stats.Panel("FPS", "#0ff", "#002")), 636 f = h(new Stats.Panel("MS", "#0f0", "#020")); 637 if (self.performance && self.performance.memory) var t = h(new Stats.Panel("MB", "#f08", "#201")); 638 k(0); 639 return { 640 REVISION: 16, 641 dom: c, 642 addPanel: h, 643 showPanel: k, 644 begin: function() { 645 g = (performance || Date).now() 646 }, 647 end: function() { 648 a++; 649 var c = (performance || Date).now(); 650 f.update(c - g, 200); 651 if (c > e + 1E3 && (r.update(1E3 * a / (c - e), 100), e = c, a = 0, t)) { 652 var d = performance.memory; 653 t.update(d.usedJSHeapSize / 1048576, d.jsHeapSizeLimit / 1048576) 654 } 655 return c 656 }, 657 update: function() { 658 g = this.end() 659 }, 660 domElement: c, 661 setMode: k 662 } 663}; 664Stats.Panel = function(h, k, l) { 665 var c = Infinity, 666 g = 0, 667 e = Math.round, 668 a = e(window.devicePixelRatio || 1), 669 r = 80 * a, 670 f = 48 * a, 671 t = 3 * a, 672 u = 2 * a, 673 d = 3 * a, 674 m = 15 * a, 675 n = 74 * a, 676 p = 30 * a, 677 q = document.createElement("canvas"); 678 q.width = r; 679 q.height = f; 680 q.style.cssText = "width:80px;height:48px"; 681 var b = q.getContext("2d"); 682 b.font = "bold " + 9 * a + "px Helvetica,Arial,sans-serif"; 683 b.textBaseline = "top"; 684 b.fillStyle = l; 685 b.fillRect(0, 0, r, f); 686 b.fillStyle = k; 687 b.fillText(h, t, u); 688 b.fillRect(d, m, n, p); 689 b.fillStyle = l; 690 b.globalAlpha = .9; 691 b.fillRect(d, m, n, p); 692 return { 693 dom: q, 694 update: function(f, 695 v) { 696 c = Math.min(c, f); 697 g = Math.max(g, f); 698 b.fillStyle = l; 699 b.globalAlpha = 1; 700 b.fillRect(0, 0, r, m); 701 b.fillStyle = k; 702 b.fillText(e(f) + " " + h + " (" + e(c) + "-" + e(g) + ")", t, u); 703 b.drawImage(q, d + a, m, n - a, p, d, m, n - a, p); 704 b.fillRect(d + n - a, m, a, p); 705 b.fillStyle = l; 706 b.globalAlpha = .9; 707 b.fillRect(d + n - a, m, a, e((1 - f / v) * p)) 708 } 709 } 710}; 711"object" === typeof module && (module.exports = Stats);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.