1// particle.min.js hosted on GitHub 2// Scroll down for initialisation code 3 4!(function (a) { 5 var b = 6 ('object' == typeof self && self.self === self && self) || 7 ('object' == typeof global && global.global === global && global); 8 'function' == typeof define && define.amd 9 ? define(['exports'], function (c) { 10 b.ParticleNetwork = a(b, c); 11 }) 12 : 'object' == typeof module && module.exports 13 ? (module.exports = a(b, {})) 14 : (b.ParticleNetwork = a(b, {})); 15})(function (a, b) { 16 var c = function (a) { 17 (this.canvas = a.canvas), 18 (this.g = a.g), 19 (this.particleColor = a.options.particleColor), 20 (this.x = Math.random() * this.canvas.width), 21 (this.y = Math.random() * this.canvas.height), 22 (this.velocity = { 23 x: (Math.random() - 0.5) * a.options.velocity, 24 y: (Math.random() - 0.5) * a.options.velocity, 25 }); 26 }; 27 return ( 28 (c.prototype.update = function () { 29 (this.x > this.canvas.width + 20 || this.x < -20) && 30 (this.velocity.x = -this.velocity.x), 31 (this.y > this.canvas.height + 20 || this.y < -20) && 32 (this.velocity.y = -this.velocity.y), 33 (this.x += this.velocity.x), 34 (this.y += this.velocity.y); 35 }), 36 (c.prototype.h = function () { 37 this.g.beginPath(), 38 (this.g.fillStyle = this.particleColor), 39 (this.g.globalAlpha = 0.7), 40 this.g.arc(this.x, this.y, 1.5, 0, 2 * Math.PI), 41 this.g.fill(); 42 }), 43 (b = function (a, b) { 44 (this.i = a), 45 (this.i.size = { 46 width: this.i.offsetWidth, 47 height: this.i.offsetHeight, 48 }), 49 (b = void 0 !== b ? b : {}), 50 (this.options = { 51 particleColor: 52 void 0 !== b.particleColor ? b.particleColor : '#fff', 53 background: 54 void 0 !== b.background ? b.background : '#1a252f', 55 interactive: void 0 !== b.interactive ? b.interactive : !0, 56 velocity: this.setVelocity(b.speed), 57 density: this.j(b.density), 58 }), 59 this.init(); 60 }), 61 (b.prototype.init = function () { 62 if ( 63 ((this.k = document.createElement('div')), 64 this.i.appendChild(this.k), 65 this.l(this.k, { 66 position: 'absolute', 67 top: 0, 68 left: 0, 69 bottom: 0, 70 right: 0, 71 'z-index': 1, 72 }), 73 /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test( 74 this.options.background 75 )) 76 ) 77 this.l(this.k, { background: this.options.background }); 78 else { 79 if ( 80 !/\.(gif|jpg|jpeg|tiff|png)$/i.test(this.options.background) 81 ) 82 return ( 83 console.error( 84 'Please specify a valid background image or hexadecimal color' 85 ), 86 !1 87 ); 88 this.l(this.k, { 89 background: 90 'url("' + 91 this.options.background + 92 '") no-repeat center', 93 'background-size': 'cover', 94 }); 95 } 96 if ( 97 !/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test( 98 this.options.particleColor 99 ) 100 ) 101 return ( 102 console.error( 103 'Please specify a valid particleColor hexadecimal color' 104 ), 105 !1 106 ); 107 (this.canvas = document.createElement('canvas')), 108 this.i.appendChild(this.canvas), 109 (this.g = this.canvas.getContext('2d')), 110 (this.canvas.width = this.i.size.width), 111 (this.canvas.height = this.i.size.height), 112 this.l(this.i, { position: 'relative' }), 113 this.l(this.canvas, { 'z-index': '20', position: 'relative' }), 114 window.addEventListener( 115 'resize', 116 function () { 117 return this.i.offsetWidth === this.i.size.width && 118 this.i.offsetHeight === this.i.size.height 119 ? !1 120 : ((this.canvas.width = this.i.size.width = this.i.offsetWidth), 121 (this.canvas.height = this.i.size.height = this.i.offsetHeight), 122 clearTimeout(this.m), 123 void (this.m = setTimeout( 124 function () { 125 this.o = []; 126 for ( 127 var a = 0; 128 a < 129 (this.canvas.width * 130 this.canvas.height) / 131 this.options.density; 132 a++ 133 ) 134 this.o.push(new c(this)); 135 this.options.interactive && 136 this.o.push(this.p), 137 requestAnimationFrame( 138 this.update.bind(this) 139 ); 140 }.bind(this), 141 500 142 ))); 143 }.bind(this) 144 ), 145 (this.o = []); 146 for ( 147 var a = 0; 148 a < 149 (this.canvas.width * this.canvas.height) / this.options.density; 150 a++ 151 ) 152 this.o.push(new c(this)); 153 this.options.interactive && 154 ((this.p = new c(this)), 155 (this.p.velocity = { x: 0, y: 0 }), 156 this.o.push(this.p), 157 this.canvas.addEventListener( 158 'mousemove', 159 function (a) { 160 (this.p.x = a.clientX - this.canvas.offsetLeft), 161 (this.p.y = a.clientY - this.canvas.offsetTop); 162 }.bind(this) 163 ), 164 this.canvas.addEventListener( 165 'mouseup', 166 function (a) { 167 (this.p.velocity = { 168 x: (Math.random() - 0.5) * this.options.velocity, 169 y: (Math.random() - 0.5) * this.options.velocity, 170 }), 171 (this.p = new c(this)), 172 (this.p.velocity = { x: 0, y: 0 }), 173 this.o.push(this.p); 174 }.bind(this) 175 )), 176 requestAnimationFrame(this.update.bind(this)); 177 }), 178 (b.prototype.update = function () { 179 this.g.clearRect(0, 0, this.canvas.width, this.canvas.height), 180 (this.g.globalAlpha = 1); 181 for (var a = 0; a < this.o.length; a++) { 182 this.o[a].update(), this.o[a].h(); 183 for (var b = this.o.length - 1; b > a; b--) { 184 var c = Math.sqrt( 185 Math.pow(this.o[a].x - this.o[b].x, 2) + 186 Math.pow(this.o[a].y - this.o[b].y, 2) 187 ); 188 c > 120 || 189 (this.g.beginPath(), 190 (this.g.strokeStyle = this.options.particleColor), 191 (this.g.globalAlpha = (120 - c) / 120), 192 (this.g.lineWidth = 0.7), 193 this.g.moveTo(this.o[a].x, this.o[a].y), 194 this.g.lineTo(this.o[b].x, this.o[b].y), 195 this.g.stroke()); 196 } 197 } 198 0 !== this.options.velocity && 199 requestAnimationFrame(this.update.bind(this)); 200 }), 201 (b.prototype.setVelocity = function (a) { 202 return 'fast' === a 203 ? 1 204 : 'slow' === a 205 ? 0.33 206 : 'none' === a 207 ? 0 208 : 0.66; 209 }), 210 (b.prototype.j = function (a) { 211 return 'high' === a 212 ? 5e3 213 : 'low' === a 214 ? 2e4 215 : isNaN(parseInt(a, 10)) 216 ? 1e4 217 : a; 218 }), 219 (b.prototype.l = function (a, b) { 220 for (var c in b) a.style[c] = b[c]; 221 }), 222 b 223 ); 224}); 225 226// Initialisation 227 228var canvasDiv = document.getElementById('particle-canvas'); 229var options = { 230 particleColor: '#fff', 231 background: '#1D1752', 232 interactive: true, 233 speed: 'medium', 234 density: 'high', 235}; 236var particleCanvas = new ParticleNetwork(canvasDiv, options);
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.