Skip to content

Commit 41a1c61

Browse files
committed
minor changes fix some bugs
1 parent 25b0480 commit 41a1c61

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

export.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,14 @@ function init(){
146146
mousePosY = mousePos.y;
147147
}, false);
148148
149-
for (var i = 0; i < MAX_PARTICLES; i++) {
149+
generateParticles();
150+
animate();
151+
}
152+
153+
function generateParticles(){
154+
for (var i = 0; i < MAX_PARTICLES; i++) {
150155
particleArray.push(createParticle());
151156
}
152-
153-
animate();
154157
}
155158
156159
function draw(){
@@ -173,25 +176,30 @@ function draw(){
173176
particle_color = "rgba("+hexToR(particle_color)+", "+hexToG(particle_color)+", "+hexToB(particle_color)+", "+OPACITY+")";
174177
}
175178
179+
c.beginPath();
180+
181+
c.lineWidth = STROKE_SIZE;
182+
c.fillStyle = particle_color;
176183
177184
if(SHADOW_BLUR>0){
178185
c.shadowBlur = SHADOW_BLUR;
179186
c.shadowOffsetX = 1;
180187
c.shadowOffsetY = 1;
181188
c.shadowColor = "rgba(100, 100, 100, 1)";
189+
}else{
190+
c.shadowBlur = null;
191+
c.shadowOffsetX = 0;
192+
c.shadowOffsetY = 0;
193+
c.shadowColor = "rgba(100, 100, 100, 0)";
182194
}
183195
184-
c.lineWidth = STROKE_SIZE;
185-
c.fillStyle = particle_color;
186-
c.beginPath();
187-
188196
var particle_stroke_color = "rgba("+hexToR(STROKE_COLOR)+", "+hexToG(STROKE_COLOR)+", "+hexToB(STROKE_COLOR)+", "+OPACITY+")";
197+
c.strokeStyle = particle_stroke_color;
189198
190199
switch (TYPE_PARTICLE){
191200
case "rect":
192201
c.fillRect(particle.x, particle.y, particle.size, particle.size);
193202
if(STROKE_SIZE>0){
194-
c.fillStyle = particle_stroke_color;
195203
c.strokeRect(particle.x, particle.y, particle.size, particle.size);
196204
}
197205
break;
@@ -200,17 +208,16 @@ function draw(){
200208
c.arc(particle.x, particle.y, radius, 0, 2 * Math.PI, false);
201209
c.fill();
202210
if(STROKE_SIZE>0){
203-
c.strokeStyle = particle_stroke_color;
204211
c.stroke();
205212
}
206213
break;
207214
case "triangle":
208215
c.moveTo(particle.x, particle.y);
209216
c.lineTo(particle.x + (particle.size*2) , particle.y);
210217
c.lineTo(particle.x + particle.size , particle.y - particle.size);
218+
c.lineTo(particle.x, particle.y);
211219
c.fill();
212220
if(STROKE_SIZE>0){
213-
c.strokeStyle = particle_stroke_color;
214221
c.stroke();
215222
}
216223
break;

main.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function generate(type){
7575
PARTICLE_SIZE:PARTICLE_SIZE,
7676
DEAD_PARTICLE:DEAD_PARTICLE,
7777
SHADOW_BLUR:SHADOW_BLUR
78-
});
78+
});
7979
}
8080

8181
window.onload = function() {
@@ -133,7 +133,7 @@ window.onload = function() {
133133
controller_dead_particle.onChange(function(value){
134134
DEAD_PARTICLE = value;
135135
});
136-
var controller_shadow_blur= gui.add(text, 'shadow_blur', 0,10);
136+
var controller_shadow_blur = gui.add(text, 'shadow_blur', 0,10);
137137
controller_shadow_blur.onFinishChange(function(value) {
138138
SHADOW_BLUR = Math.round(value);
139139
});
@@ -215,11 +215,14 @@ function init(){
215215
mousePosY = mousePos.y;
216216
}, false);
217217

218-
for (var i = 0; i < MAX_PARTICLES; i++) {
218+
generateParticles();
219+
animate();
220+
}
221+
222+
function generateParticles(){
223+
for (var i = 0; i < MAX_PARTICLES; i++) {
219224
particleArray.push(createParticle());
220225
}
221-
222-
animate();
223226
}
224227

225228
function draw(){
@@ -242,25 +245,30 @@ function draw(){
242245
particle_color = "rgba("+hexToR(particle_color)+", "+hexToG(particle_color)+", "+hexToB(particle_color)+", "+OPACITY+")";
243246
}
244247

248+
c.beginPath();
249+
250+
c.lineWidth = STROKE_SIZE;
251+
c.fillStyle = particle_color;
245252

246253
if(SHADOW_BLUR>0){
247254
c.shadowBlur = SHADOW_BLUR;
248255
c.shadowOffsetX = 1;
249256
c.shadowOffsetY = 1;
250257
c.shadowColor = "rgba(100, 100, 100, 1)";
258+
}else{
259+
c.shadowBlur = null;
260+
c.shadowOffsetX = 0;
261+
c.shadowOffsetY = 0;
262+
c.shadowColor = "rgba(100, 100, 100, 0)";
251263
}
252264

253-
c.lineWidth = STROKE_SIZE;
254-
c.fillStyle = particle_color;
255-
c.beginPath();
256-
257265
var particle_stroke_color = "rgba("+hexToR(STROKE_COLOR)+", "+hexToG(STROKE_COLOR)+", "+hexToB(STROKE_COLOR)+", "+OPACITY+")";
266+
c.strokeStyle = particle_stroke_color;
258267

259268
switch (TYPE_PARTICLE){
260269
case 'rect':
261270
c.fillRect(particle.x, particle.y, particle.size, particle.size);
262271
if(STROKE_SIZE>0){
263-
c.fillStyle = particle_stroke_color;
264272
c.strokeRect(particle.x, particle.y, particle.size, particle.size);
265273
}
266274
break;
@@ -269,17 +277,16 @@ function draw(){
269277
c.arc(particle.x, particle.y, radius, 0, 2 * Math.PI, false);
270278
c.fill();
271279
if(STROKE_SIZE>0){
272-
c.strokeStyle = particle_stroke_color;
273280
c.stroke();
274281
}
275282
break;
276283
case 'triangle':
277284
c.moveTo(particle.x, particle.y);
278285
c.lineTo(particle.x + (particle.size*2) , particle.y);
279286
c.lineTo(particle.x + particle.size , particle.y - particle.size);
287+
c.lineTo(particle.x, particle.y);
280288
c.fill();
281289
if(STROKE_SIZE>0){
282-
c.strokeStyle = particle_stroke_color;
283290
c.stroke();
284291
}
285292
break;
@@ -296,7 +303,6 @@ function draw(){
296303
particleArray[i] = createParticle();
297304
}
298305
}else{
299-
300306
if(particle.x < -(particle.size) ||
301307
particle.y < -(particle.size) ||
302308
particle.x > window.innerWidth+particle.size ||

0 commit comments

Comments
 (0)