Apply prettier formatting

This commit is contained in:
Michael Weimann 2022-12-12 12:24:14 +01:00
parent 1cac306093
commit 526645c791
No known key found for this signature in database
GPG key ID: 53F535A266BB9584
1576 changed files with 65385 additions and 62478 deletions

View file

@ -15,7 +15,7 @@
limitations under the License.
*/
import ICanvasEffect from '../ICanvasEffect';
import ICanvasEffect from "../ICanvasEffect";
export type FireworksOptions = {
/**
@ -76,7 +76,7 @@ export default class Fireworks implements ICanvasEffect {
return;
}
this.isRunning = true;
this.context = canvas.getContext('2d');
this.context = canvas.getContext("2d");
this.supportsAnimationFrame.call(window, this.updateWorld);
if (timeout) {
window.setTimeout(this.stop, timeout);
@ -95,7 +95,7 @@ export default class Fireworks implements ICanvasEffect {
this.createFirework();
}
const alive = [];
for (let i=0; i<this.particles.length; i++) {
for (let i = 0; i < this.particles.length; i++) {
if (this.move(this.particles[i])) {
alive.push(this.particles[i]);
}
@ -105,11 +105,11 @@ export default class Fireworks implements ICanvasEffect {
private paint = () => {
if (!this.context || !this.context.canvas) return;
this.context.globalCompositeOperation = 'destination-out';
this.context.globalCompositeOperation = "destination-out";
this.context.fillStyle = "rgba(0,0,0,0.5)";
this.context.fillRect(0, 0, this.context.canvas.width, this.context.canvas.height);
this.context.globalCompositeOperation = 'lighter';
for (let i=0; i<this.particles.length; i++) {
this.context.globalCompositeOperation = "lighter";
for (let i = 0; i < this.particles.length; i++) {
this.drawParticle(this.particles[i]);
}
};
@ -121,20 +121,26 @@ export default class Fireworks implements ICanvasEffect {
const xPoint = Math.random() * (width - 200) + 100;
const yPoint = Math.random() * (height - 200) + 100;
const nFire = Math.random() * 50 + 100;
const color = "rgb("+(~~(Math.random()*200+55))+","
+(~~(Math.random()*200+55))+","+(~~(Math.random()*200+55))+")";
for (let i=0; i<nFire; i++) {
const color =
"rgb(" +
~~(Math.random() * 200 + 55) +
"," +
~~(Math.random() * 200 + 55) +
"," +
~~(Math.random() * 200 + 55) +
")";
for (let i = 0; i < nFire; i++) {
const particle = <FireworksParticle>{};
particle.color = color;
particle.w = particle.h = Math.random() * 4 + 1;
particle.x = xPoint - particle.w / 2;
particle.y = yPoint - particle.h / 2;
particle.vx = (Math.random()-0.5)*10;
particle.vy = (Math.random()-0.5)*10;
particle.alpha = Math.random()*.5+.5;
particle.vx = (Math.random() - 0.5) * 10;
particle.vy = (Math.random() - 0.5) * 10;
particle.alpha = Math.random() * 0.5 + 0.5;
const vy = Math.sqrt(25 - particle.vx * particle.vx);
if (Math.abs(particle.vy) > vy) {
particle.vy = particle.vy > 0 ? vy: -vy;
particle.vy = particle.vy > 0 ? vy : -vy;
}
this.particles.push(particle);
}
@ -166,8 +172,11 @@ export default class Fireworks implements ICanvasEffect {
particle.vy += this.options.gravity;
particle.y += particle.vy;
particle.alpha -= 0.01;
return !(particle.x <= -particle.w || particle.x >= screen.width ||
return !(
particle.x <= -particle.w ||
particle.x >= screen.width ||
particle.y >= screen.height ||
particle.alpha <= 0);
particle.alpha <= 0
);
};
}