Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit 0024749

Browse files
author
Marc Brüderlin
committed
Merge branch 'release-1.0.2'
2 parents a8bc304 + 88d5a15 commit 0024749

5 files changed

Lines changed: 53 additions & 41 deletions

File tree

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ particles.js is a lightweight (~2kb) and dependency-free javascript plugin for p
1010
There are several ways to install particles.js:
1111
- [Download the latest version](https://github.com/marcbruederlin/particles.js/archive/master.zip)
1212
- Install with npm: `npm install particlesjs --save`
13-
- Use the CDN: `https://unpkg.com/particlesjs@1.0.1/dist/particles.min.js`
13+
- Use the CDN: `https://npmcdn.com/particlesjs@1.0.2/dist/particles.min.js`
1414

1515
## Usage
1616
Include the minified JS in your HTML file.
@@ -44,6 +44,14 @@ Initialize the plugin on the `window.onload` event.
4444
window.onload = function() {
4545
Particles.init({ options });
4646
};
47+
48+
// e.g.
49+
window.onload = function() {
50+
Particles.init({
51+
selector: '#myCanvas',
52+
color: '#0f9976'
53+
});
54+
};
4755
```
4856

4957
## Options
@@ -59,20 +67,20 @@ Option | Default | Description
5967

6068

6169
## Browser Support
62-
IE10+ and all modern browsers.
70+
IE9+ and all modern browsers.
6371

6472
## Build
6573
To compile the distribution files by yourself, make sure that you have node.js and gulp installed, then:
6674
- Clone the repository: `https://github.com/marcbruederlin/particles.js.git`
6775
- Change in the project directory: `cd particles.js`
6876
- Install the dependencies: `npm install`
69-
- Run the gulp build task `gulp build` to regenerate the `dist` folder. You can also run `gulp build --watch` to watch for file changes and automatically rebuild the files.
77+
- Run the gulp build task `gulp build` to regenerate the `dist` folder. <br/> You can also run `gulp build --watch` to watch for file changes and automatically rebuild the files.
7078

7179
## Using particles.js?
72-
If you’re using particles.js in some interesting way or on a cool site, I’d be very grateful if you <a href="mailto:hello@marcbruederlin.com?subject=Hey, I'm using particles.js">shoot me</a> a link to it.
73-
If you want, you can [buy me a coffee](https://www.paypal.me/marcbruederlin) to keep this project running.
80+
If you’re using particles.js in some interesting way or on a cool site, I’d be very grateful if you <a href="mailto:hello@marcbruederlin.com?subject=Hey, I'm using particles.js">shoot me</a> a link to it.<br />
81+
For any problems or questions don't hesitate to open an issue.<br />
82+
Do you like particles.js? If you want, you can [buy me a coffee](https://www.paypal.me/marcbruederlin).
7483

7584
## License
7685
particles.js is created by [Marc Brüderlin](https://marcbruederlin.com) and released
77-
under the [MIT license](https://github.com/marcbruederlin/particles.js/blob/master/LICENSE).
78-
For any problem or question do not hesitate to open an issue.
86+
under the [MIT license](https://github.com/marcbruederlin/particles.js/blob/master/LICENSE).

dist/particles.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
* for particle backgrounds.
44
*
55
* @author Marc Brüderlin <hello@marcbruederlin.com>
6-
* @version 1.0.0
6+
* @version 1.0.2
77
* @license MIT
8-
* @see https://marcbruederlin.github.io/particles.js/
8+
* @see https://github.com/marcbruederlin/particles.js
99
*/
10+
11+
/* exported Particles */
1012
var Particles = (function(window, document) {
1113
'use strict';
1214

@@ -38,7 +40,7 @@ var Particles = (function(window, document) {
3840
window.addEventListener('resize', this.resize.bind(this), false);
3941

4042
// Check if options and a selector are specified
41-
if(options === undefined || !options.selector) {
43+
if (options === undefined || !options.selector) {
4244
console.warn('particles.js: No selector is specified! Check https://github.com/marcbruederlin/particles.js#options');
4345
return false;
4446
}
@@ -56,7 +58,7 @@ var Particles = (function(window, document) {
5658
canvas.height = window.innerHeight;
5759

5860
// Fill the storage with the given amount of particle instances
59-
for(var i = config.maxParticles; i--;) {
61+
for (var i = config.maxParticles; i--;) {
6062
this.storage.push(new Particle());
6163
}
6264

@@ -78,7 +80,7 @@ var Particles = (function(window, document) {
7880
this.draw = function() {
7981
context.clearRect(0, 0, canvas.width, canvas.height);
8082

81-
for(var i = this.storage.length; i--;) {
83+
for (var i = this.storage.length; i--;) {
8284
var particle = this.storage[i];
8385
particle.draw();
8486
}
@@ -90,26 +92,26 @@ var Particles = (function(window, document) {
9092
* Calculates the position and movement for each particle.
9193
*/
9294
this.update = function() {
93-
for(var i = this.storage.length; i--;) {
95+
for (var i = this.storage.length; i--;) {
9496
var particle = this.storage[i];
9597

9698
particle.x += particle.vx;
9799
particle.y += particle.vy;
98100

99-
if(particle.x + particle.radius > canvas.width) {
101+
if (particle.x + particle.radius > canvas.width) {
100102
particle.x = particle.radius;
101-
} else if(particle.x - particle.radius < 0) {
103+
} else if (particle.x - particle.radius < 0) {
102104
particle.x = canvas.width - particle.radius;
103105
}
104106

105-
if(particle.y + particle.radius > canvas.height) {
107+
if (particle.y + particle.radius > canvas.height) {
106108
particle.y = particle.radius;
107-
} else if(particle.y - particle.radius < 0) {
109+
} else if (particle.y - particle.radius < 0) {
108110
particle.y = canvas.height - particle.radius;
109111
}
110112

111-
if(config.connectParticles) {
112-
for(var j = i + 1; j < this.storage.length; j++) {
113+
if (config.connectParticles) {
114+
for (var j = i + 1; j < this.storage.length; j++) {
113115
var particle2 = this.storage[j];
114116

115117
this.distance(particle, particle2);
@@ -128,7 +130,7 @@ var Particles = (function(window, document) {
128130
n = Math.sqrt(r * r + dy * dy);
129131

130132
// Draw a connective line between this two points if the distance is lesser or equal the minimum distance
131-
if(n <= config.minDistance) {
133+
if (n <= config.minDistance) {
132134
context.beginPath();
133135
context.strokeStyle = 'rgba(' + config.color.r + ', ' + config.color.g + ', ' + config.color.b + ', ' + (1.2 - n / config.minDistance) + ')';
134136
context.moveTo(p1.x, p1.y);

dist/particles.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "particlesjs",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "A lightweight and dependency-free javascript plugin for particle backgrounds.",
5-
"main": "dist/particles.js",
5+
"main": "dist/particles.min.js",
66
"repository": {
77
"type": "git",
88
"url": "git+https://github.com/marcbruederlin/particles.js"
@@ -25,9 +25,9 @@
2525
"gulp-jshint": "^2.0.1",
2626
"gulp-rename": "^1.2.2",
2727
"gulp-uglify": "^2.0.0",
28-
"gulp-watch": "^4.3.8",
29-
"jshint": "^2.9.2",
30-
"jshint-stylish": "^2.2.0",
31-
"yargs": "^4.8.1"
28+
"gulp-watch": "^4.3.10",
29+
"jshint": "^2.9.3",
30+
"jshint-stylish": "^2.2.1",
31+
"yargs": "^6.0.0"
3232
}
3333
}

src/particles.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
* for particle backgrounds.
44
*
55
* @author Marc Brüderlin <hello@marcbruederlin.com>
6-
* @version 1.0.1
6+
* @version 1.0.2
77
* @license MIT
8-
* @see https://marcbruederlin.github.io/particles.js/
8+
* @see https://github.com/marcbruederlin/particles.js
99
*/
10+
11+
/* exported Particles */
1012
var Particles = (function(window, document) {
1113
'use strict';
1214

@@ -38,7 +40,7 @@ var Particles = (function(window, document) {
3840
window.addEventListener('resize', this.resize.bind(this), false);
3941

4042
// Check if options and a selector are specified
41-
if(options === undefined || !options.selector) {
43+
if (options === undefined || !options.selector) {
4244
console.warn('particles.js: No selector is specified! Check https://github.com/marcbruederlin/particles.js#options');
4345
return false;
4446
}
@@ -56,7 +58,7 @@ var Particles = (function(window, document) {
5658
canvas.height = window.innerHeight;
5759

5860
// Fill the storage with the given amount of particle instances
59-
for(var i = config.maxParticles; i--;) {
61+
for (var i = config.maxParticles; i--;) {
6062
this.storage.push(new Particle());
6163
}
6264

@@ -78,7 +80,7 @@ var Particles = (function(window, document) {
7880
this.draw = function() {
7981
context.clearRect(0, 0, canvas.width, canvas.height);
8082

81-
for(var i = this.storage.length; i--;) {
83+
for (var i = this.storage.length; i--;) {
8284
var particle = this.storage[i];
8385
particle.draw();
8486
}
@@ -90,26 +92,26 @@ var Particles = (function(window, document) {
9092
* Calculates the position and movement for each particle.
9193
*/
9294
this.update = function() {
93-
for(var i = this.storage.length; i--;) {
95+
for (var i = this.storage.length; i--;) {
9496
var particle = this.storage[i];
9597

9698
particle.x += particle.vx;
9799
particle.y += particle.vy;
98100

99-
if(particle.x + particle.radius > canvas.width) {
101+
if (particle.x + particle.radius > canvas.width) {
100102
particle.x = particle.radius;
101-
} else if(particle.x - particle.radius < 0) {
103+
} else if (particle.x - particle.radius < 0) {
102104
particle.x = canvas.width - particle.radius;
103105
}
104106

105-
if(particle.y + particle.radius > canvas.height) {
107+
if (particle.y + particle.radius > canvas.height) {
106108
particle.y = particle.radius;
107-
} else if(particle.y - particle.radius < 0) {
109+
} else if (particle.y - particle.radius < 0) {
108110
particle.y = canvas.height - particle.radius;
109111
}
110112

111-
if(config.connectParticles) {
112-
for(var j = i + 1; j < this.storage.length; j++) {
113+
if (config.connectParticles) {
114+
for (var j = i + 1; j < this.storage.length; j++) {
113115
var particle2 = this.storage[j];
114116

115117
this.distance(particle, particle2);
@@ -128,7 +130,7 @@ var Particles = (function(window, document) {
128130
n = Math.sqrt(r * r + dy * dy);
129131

130132
// Draw a connective line between this two points if the distance is lesser or equal the minimum distance
131-
if(n <= config.minDistance) {
133+
if (n <= config.minDistance) {
132134
context.beginPath();
133135
context.strokeStyle = 'rgba(' + config.color.r + ', ' + config.color.g + ', ' + config.color.b + ', ' + (1.2 - n / config.minDistance) + ')';
134136
context.moveTo(p1.x, p1.y);

0 commit comments

Comments
 (0)