@@ -15,82 +15,198 @@ Load particles.js and configure the particles:
15
15
16
16
** app.js**
17
17
``` javascript
18
- /* particlesJS('dom-id', params);
19
- /* @dom-id : set the html tag id [string, optional, default value : particles-js]
20
- /* @params: set the params [object, optional, default values : check particles.js] */
18
+ /* particlesJS.load(@dom-id, @path-json, @callback (optional)); */
19
+ particlesJS .load (' particles-js' , ' assets/particles.json' , function () {
20
+ console .log (' callback - particles-js config loaded' );
21
+ });
22
+ ```
21
23
22
- /* config dom id (optional) + config particles params */
23
- particlesJS (' particles-js' , {
24
- particles: {
25
- color: ' #fff' ,
26
- color_random: false ,
27
- shape: ' circle' , // "circle", "edge" or "triangle"
28
- opacity: {
29
- opacity: 1 ,
30
- anim: {
31
- enable: true ,
32
- speed: 1.5 ,
33
- opacity_min: 0 ,
34
- sync: false
24
+ ** particles.json**
25
+ ``` javascript
26
+ {
27
+ " particles" : {
28
+ " number" : {
29
+ " value" : 80 ,
30
+ " density" : {
31
+ " enable" : true ,
32
+ " value_area" : 800
33
+ }
34
+ },
35
+ " color" : {
36
+ " value" : " #ffffff"
37
+ },
38
+ " shape" : {
39
+ " type" : " circle" ,
40
+ " stroke" : {
41
+ " width" : 0 ,
42
+ " color" : " #000000"
43
+ },
44
+ " polygon" : {
45
+ " nb_sides" : 5
46
+ },
47
+ " image" : {
48
+ " src" : " img/github.svg" ,
49
+ " width" : 100 ,
50
+ " height" : 100
51
+ }
52
+ },
53
+ " opacity" : {
54
+ " value" : 0.5 ,
55
+ " random" : false ,
56
+ " anim" : {
57
+ " enable" : false ,
58
+ " speed" : 1 ,
59
+ " opacity_min" : 0.1 ,
60
+ " sync" : false
35
61
}
36
62
},
37
- size: 4 ,
38
- size_random: true ,
39
- nb: 150 ,
40
- line_linked: {
41
- enable_auto: true ,
42
- distance: 100 ,
43
- color: ' #fff' ,
44
- opacity: 1 ,
45
- width: 1 ,
46
- condensed_mode: {
47
- enable: false ,
48
- rotateX: 600 ,
49
- rotateY: 600
63
+ " size" : {
64
+ " value" : 10 ,
65
+ " random" : true ,
66
+ " anim" : {
67
+ " enable" : false ,
68
+ " speed" : 80 ,
69
+ " size_min" : 0.1 ,
70
+ " sync" : false
50
71
}
51
72
},
52
- anim: {
53
- enable: true ,
54
- speed: 1
73
+ " line_linked" : {
74
+ " enable" : true ,
75
+ " distance" : 300 ,
76
+ " color" : " #ffffff" ,
77
+ " opacity" : 0.4 ,
78
+ " width" : 2
79
+ },
80
+ " move" : {
81
+ " enable" : true ,
82
+ " speed" : 12 ,
83
+ " direction" : " none" ,
84
+ " random" : false ,
85
+ " straight" : false ,
86
+ " out_mode" : " out" ,
87
+ " bounce" : false ,
88
+ " attract" : {
89
+ " enable" : false ,
90
+ " rotateX" : 600 ,
91
+ " rotateY" : 1200
92
+ }
55
93
}
56
94
},
57
- interactivity: {
58
- enable: true ,
59
- mouse: {
60
- distance: 300
61
- },
62
- detect_on: ' canvas' , // "canvas" or "window"
63
- mode: ' grab' , // "grab" of false
64
- line_linked: {
65
- opacity: .5
95
+ " interactivity" : {
96
+ " detect_on" : " canvas" ,
97
+ " events" : {
98
+ " onhover" : {
99
+ " enable" : false ,
100
+ " mode" : " repulse"
101
+ },
102
+ " onclick" : {
103
+ " enable" : true ,
104
+ " mode" : " push"
105
+ },
106
+ " resize" : true
66
107
},
67
- events: {
68
- onclick: {
69
- enable: true ,
70
- mode: ' push' , // "push" or "remove"
71
- nb: 4
108
+ " modes" : {
109
+ " grab" : {
110
+ " distance" : 800 ,
111
+ " line_linked" : {
112
+ " opacity" : 1
113
+ }
114
+ },
115
+ " bubble" : {
116
+ " distance" : 800 ,
117
+ " size" : 80 ,
118
+ " duration" : 2 ,
119
+ " opacity" : 8 ,
120
+ " speed" : 3
121
+ },
122
+ " repulse" : {
123
+ " distance" : 400 ,
124
+ " duration" : 0.4
125
+ },
126
+ " push" : {
127
+ " particles_nb" : 4
72
128
},
73
- onresize: {
74
- enable: true ,
75
- mode: ' out' , // "out" or "bounce"
76
- density_auto: false ,
77
- density_area: 800 // nb_particles = particles.nb * (canvas width * canvas height / 1000) / density_area
129
+ " remove" : {
130
+ " particles_nb" : 2
78
131
}
79
132
}
80
133
},
81
- /* Retina Display Support */
82
- retina_detect: true
83
- });
134
+ " retina_detect" : true
135
+ }
84
136
```
137
+
85
138
-------------------------------
86
- ### *** Live Demo***
87
- <a href =" http://codepen.io/VincentGarreau/pen/pnlso " target =" _blank " >CodePen demo</a >
88
139
89
- <a href =" http://htmlpreview.github.io/?https://github.com/VincentGarreau/particles.js/blob/master/demo/index.html " target =" _blank " >GitHub demo</a >
140
+ ### ` Options `
141
+
142
+ key | option type / notes | example
143
+ ----|---------|------|------
144
+ ` particles.number.value ` | number | ` 40 `
145
+ ` particles.number.density.enable ` | boolean | ` true ` / ` false `
146
+ ` particles.number.density.value_area ` | number | ` 800 `
147
+ ` particles.color.value ` | HEX (string) <br /> RGB (object) <br /> HSL (object) <br /> array selection (HEX) <br /> random (string) | ` "#b61924" ` <br /> ` {r:182, g:25, b:36} ` <br /> ` {h:356, s:76, l:41} ` <br /> ` ["#b61924", "#333333", "999999"] ` <br /> ` "random" `
148
+ ` particles.number.density.value_area ` | number | ` 800 `
149
+ ` particles.shape.type ` | string <br /> array selection | ` "circle" ` <br /> ` "edge" ` <br /> ` "triangle" ` <br /> ` "polygon" ` <br /> ` "star" ` <br /> ` "image" ` <br /> ` ["circle", "triangle", "image"] `
150
+ ` particles.shape.stroke.width ` | number | ` 2 `
151
+ ` particles.shape.stroke.color ` | HEX (string) | ` "#222222" `
152
+ ` particles.shape.polygon.nb_slides ` | number | ` 5 `
153
+ ` particles.shape.image.src ` | path link <br /> svg / png / gif / jpg | ` "assets/img/yop.svg" ` <br /> ` "http://mywebsite.com/assets/img/yop.png" `
154
+ ` particles.shape.image.width ` | number <br />(for aspect ratio) | ` 100 `
155
+ ` particles.shape.image.height ` | number <br />(for aspect ratio) | ` 100 `
156
+ ` particles.opacity.value ` | number (0 to 1) | ` 0.75 `
157
+ ` particles.opacity.random ` | boolean | ` true ` / ` false `
158
+ ` particles.opacity.anim.enable ` | boolean | ` true ` / ` false `
159
+ ` particles.opacity.anim.speed ` | number | ` 3 `
160
+ ` particles.opacity.anim.opacity_min ` | number (0 to 1) | ` 0.25 `
161
+ ` particles.opacity.anim.sync ` | boolean | ` true ` / ` false `
162
+ ` particles.size.value ` | number | ` 20 `
163
+ ` particles.size.random ` | boolean | ` true ` / ` false `
164
+ ` particles.size.anim.enable ` | boolean | ` true ` / ` false `
165
+ ` particles.size.anim.speed ` | number | ` 3 `
166
+ ` particles.size.anim.size_min ` | number | ` 0.25 `
167
+ ` particles.size.anim.sync ` | boolean | ` true ` / ` false `
168
+ ` particles.line_linked.enable ` | boolean | ` true ` / ` false `
169
+ ` particles.line_linked.distance ` | number | ` 150 `
170
+ ` particles.line_linked.color ` | HEX (string) | ` #ffffff `
171
+ ` particles.line_linked.opacity ` | number (0 to 1) | ` 0.5 `
172
+ ` particles.line_linked.width ` | number | ` 1.5 `
173
+ ` particles.move.enable ` | boolean | ` true ` / ` false `
174
+ ` particles.move.speed ` | number | ` 4 `
175
+ ` particles.move.direction ` | string | ` "none" ` <br /> ` "top" ` <br /> ` "top-right" ` <br /> ` "right" ` <br /> ` "bottom-right" ` <br /> ` "bottom" ` <br /> ` "bottom-left" ` <br /> ` "left" ` <br /> ` "top-left" `
176
+ ` particles.move.random ` | boolean | ` true ` / ` false `
177
+ ` particles.move.straight ` | boolean | ` true ` / ` false `
178
+ ` particles.move.out_mode ` | string <br /> (out of canvas) | ` "out" ` <br /> ` "bounce" `
179
+ ` particles.move.bounce ` | boolean <br /> (between particles) | ` true ` / ` false `
180
+ ` particles.move.attract.enable ` | boolean | ` true ` / ` false `
181
+ ` particles.move.attract.rotateX ` | number | ` 3000 `
182
+ ` particles.move.attract.rotateY ` | number | ` 1500 `
183
+ ` interactivity.detect_on ` | string | ` "canvas", "window" `
184
+ ` interactivity.events.onhover.enable ` | boolean | ` true ` / ` false `
185
+ ` interactivity.events.onhover.mode ` | string <br /> array selection | ` "grab" ` <br /> ` "bubble" ` <br /> ` "repulse" ` <br /> ` ["grab", "bubble"] `
186
+ ` interactivity.events.onclick.enable ` | boolean | ` true ` / ` false `
187
+ ` interactivity.events.onclick.mode ` | string <br /> array selection | ` "push" ` <br /> ` "remove" ` <br /> ` "bubble" ` <br /> ` "repulse" ` <br /> ` ["push", "repulse"] `
188
+ ` interactivity.events.resize ` | boolean | ` true ` / ` false `
189
+ ` interactivity.events.modes.grab.distance ` | number | ` 100 `
190
+ ` interactivity.events.modes.grab.line_linked.opacity ` | number (0 to 1) | ` 0.75 `
191
+ ` interactivity.events.modes.bubble.distance ` | number | ` 100 `
192
+ ` interactivity.events.modes.bubble.size ` | number | ` 40 `
193
+ ` interactivity.events.modes.bubble.duration ` | number <br /> (second) | ` 0.4 `
194
+ ` interactivity.events.modes.repulse.distance ` | number | ` 200 `
195
+ ` interactivity.events.modes.repulse.duration ` | number <br /> (second) | ` 1.2 `
196
+ ` interactivity.events.modes.push.particles_nb ` | number | ` 4 `
197
+ ` interactivity.events.modes.push.particles_nb ` | number | ` 4 `
198
+ ` retina_detect ` | boolean | ` true ` / ` false `
90
199
91
200
-------------------------------
92
201
93
- ##### *** Install with Bower***
202
+ ### ` Packages install `
203
+
204
+ ##### *** Bower***
94
205
```
95
206
bower install particles.js --save
96
207
```
208
+
209
+ ##### *** Rails Assets***
210
+ ```
211
+ gem 'rails-assets-particles.js'
212
+ ```
0 commit comments