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