Apply prettier formatting
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
import ICanvasEffect from '../ICanvasEffect';
|
||||
import ICanvasEffect from "../ICanvasEffect";
|
||||
|
||||
export type ConfettiOptions = {
|
||||
/**
|
||||
@@ -67,10 +67,20 @@ export default class Confetti implements ICanvasEffect {
|
||||
|
||||
private context: CanvasRenderingContext2D | null = null;
|
||||
private supportsAnimationFrame = window.requestAnimationFrame;
|
||||
private colors = ['rgba(30,144,255,', 'rgba(107,142,35,', 'rgba(255,215,0,',
|
||||
'rgba(255,192,203,', 'rgba(106,90,205,', 'rgba(173,216,230,',
|
||||
'rgba(238,130,238,', 'rgba(152,251,152,', 'rgba(70,130,180,',
|
||||
'rgba(244,164,96,', 'rgba(210,105,30,', 'rgba(220,20,60,'];
|
||||
private colors = [
|
||||
"rgba(30,144,255,",
|
||||
"rgba(107,142,35,",
|
||||
"rgba(255,215,0,",
|
||||
"rgba(255,192,203,",
|
||||
"rgba(106,90,205,",
|
||||
"rgba(173,216,230,",
|
||||
"rgba(238,130,238,",
|
||||
"rgba(152,251,152,",
|
||||
"rgba(70,130,180,",
|
||||
"rgba(244,164,96,",
|
||||
"rgba(210,105,30,",
|
||||
"rgba(220,20,60,",
|
||||
];
|
||||
|
||||
private lastFrameTime = Date.now();
|
||||
private particles: Array<ConfettiParticle> = [];
|
||||
@@ -82,7 +92,7 @@ export default class Confetti implements ICanvasEffect {
|
||||
if (!canvas) {
|
||||
return;
|
||||
}
|
||||
this.context = canvas.getContext('2d');
|
||||
this.context = canvas.getContext("2d");
|
||||
this.particles = [];
|
||||
const count = this.options.maxCount;
|
||||
while (this.particles.length < count) {
|
||||
@@ -100,9 +110,9 @@ export default class Confetti implements ICanvasEffect {
|
||||
};
|
||||
|
||||
private resetParticle = (particle: ConfettiParticle, width: number, height: number): ConfettiParticle => {
|
||||
particle.color = this.colors[(Math.random() * this.colors.length) | 0] + (this.options.alpha + ')');
|
||||
particle.color = this.colors[(Math.random() * this.colors.length) | 0] + (this.options.alpha + ")");
|
||||
if (this.options.gradient) {
|
||||
particle.color2 = this.colors[(Math.random() * this.colors.length) | 0] + (this.options.alpha + ')');
|
||||
particle.color2 = this.colors[(Math.random() * this.colors.length) | 0] + (this.options.alpha + ")");
|
||||
} else {
|
||||
particle.color2 = particle.color;
|
||||
}
|
||||
@@ -138,7 +148,9 @@ export default class Confetti implements ICanvasEffect {
|
||||
if (!this.context || !this.context.canvas) {
|
||||
return;
|
||||
}
|
||||
let x; let x2; let y2;
|
||||
let x;
|
||||
let x2;
|
||||
let y2;
|
||||
for (const particle of this.particles) {
|
||||
this.context.beginPath();
|
||||
context.lineWidth = particle.diameter;
|
||||
|
||||
@@ -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
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
import ICanvasEffect from '../ICanvasEffect';
|
||||
import ICanvasEffect from "../ICanvasEffect";
|
||||
import { arrayFastClone } from "../../utils/arrays";
|
||||
|
||||
export type HeartOptions = {
|
||||
@@ -68,18 +68,19 @@ export default class Hearts implements ICanvasEffect {
|
||||
private lastAnimationTime: number;
|
||||
|
||||
private colours = [
|
||||
'rgba(194,210,224,1)',
|
||||
'rgba(235,214,219,1)',
|
||||
'rgba(255,211,45,1)',
|
||||
'rgba(255,190,174,1)',
|
||||
'rgba(255,173,226,1)',
|
||||
'rgba(242,114,171,1)',
|
||||
'rgba(228,55,116,1)',
|
||||
'rgba(255,86,130,1)',
|
||||
'rgba(244,36,57,1)',
|
||||
'rgba(247,126,157,1)',
|
||||
'rgba(243,142,140,1)',
|
||||
'rgba(252,116,183,1)'];
|
||||
"rgba(194,210,224,1)",
|
||||
"rgba(235,214,219,1)",
|
||||
"rgba(255,211,45,1)",
|
||||
"rgba(255,190,174,1)",
|
||||
"rgba(255,173,226,1)",
|
||||
"rgba(242,114,171,1)",
|
||||
"rgba(228,55,116,1)",
|
||||
"rgba(255,86,130,1)",
|
||||
"rgba(244,36,57,1)",
|
||||
"rgba(247,126,157,1)",
|
||||
"rgba(243,142,140,1)",
|
||||
"rgba(252,116,183,1)",
|
||||
];
|
||||
|
||||
public isRunning: boolean;
|
||||
|
||||
@@ -87,7 +88,7 @@ export default class Hearts implements ICanvasEffect {
|
||||
if (!canvas) {
|
||||
return;
|
||||
}
|
||||
this.context = canvas.getContext('2d');
|
||||
this.context = canvas.getContext("2d");
|
||||
this.particles = [];
|
||||
const count = this.options.maxCount;
|
||||
while (this.particles.length < count) {
|
||||
@@ -109,10 +110,10 @@ export default class Hearts implements ICanvasEffect {
|
||||
particle.x = Math.random() * width;
|
||||
particle.y = Math.random() * height + height;
|
||||
particle.xCol = particle.x;
|
||||
particle.scale = (Math.random() * 0.07) + 0.04;
|
||||
particle.maximumDrift = (Math.random() * this.options.maxDrift) + 3.5;
|
||||
particle.maximumRot = (Math.random() * this.options.maxRot) + 3.5;
|
||||
particle.gravity = this.options.gravity + (Math.random() * 4.8);
|
||||
particle.scale = Math.random() * 0.07 + 0.04;
|
||||
particle.maximumDrift = Math.random() * this.options.maxDrift + 3.5;
|
||||
particle.maximumRot = Math.random() * this.options.maxRot + 3.5;
|
||||
particle.gravity = this.options.gravity + Math.random() * 4.8;
|
||||
return particle;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ import { HeartOptions } from "./hearts";
|
||||
*/
|
||||
export const CHAT_EFFECTS: Array<Effect<{ [key: string]: any }>> = [
|
||||
{
|
||||
emojis: ['🎊', '🎉'],
|
||||
msgType: 'nic.custom.confetti',
|
||||
command: 'confetti',
|
||||
emojis: ["🎊", "🎉"],
|
||||
msgType: "nic.custom.confetti",
|
||||
command: "confetti",
|
||||
description: () => _td("Sends the given message with confetti"),
|
||||
fallbackMessage: () => _t("sends confetti") + " 🎉",
|
||||
options: {
|
||||
@@ -42,9 +42,9 @@ export const CHAT_EFFECTS: Array<Effect<{ [key: string]: any }>> = [
|
||||
},
|
||||
} as Effect<ConfettiOptions>,
|
||||
{
|
||||
emojis: ['🎆'],
|
||||
msgType: 'nic.custom.fireworks',
|
||||
command: 'fireworks',
|
||||
emojis: ["🎆"],
|
||||
msgType: "nic.custom.fireworks",
|
||||
command: "fireworks",
|
||||
description: () => _td("Sends the given message with fireworks"),
|
||||
fallbackMessage: () => _t("sends fireworks") + " 🎆",
|
||||
options: {
|
||||
@@ -53,9 +53,9 @@ export const CHAT_EFFECTS: Array<Effect<{ [key: string]: any }>> = [
|
||||
},
|
||||
} as Effect<FireworksOptions>,
|
||||
{
|
||||
emojis: ['🌧️', '⛈️', '🌦️'],
|
||||
msgType: 'io.element.effect.rainfall',
|
||||
command: 'rainfall',
|
||||
emojis: ["🌧️", "⛈️", "🌦️"],
|
||||
msgType: "io.element.effect.rainfall",
|
||||
command: "rainfall",
|
||||
description: () => _td("Sends the given message with rainfall"),
|
||||
fallbackMessage: () => _t("sends rainfall") + " 🌧️",
|
||||
options: {
|
||||
@@ -64,9 +64,9 @@ export const CHAT_EFFECTS: Array<Effect<{ [key: string]: any }>> = [
|
||||
},
|
||||
} as Effect<RainfallOptions>,
|
||||
{
|
||||
emojis: ['❄', '🌨'],
|
||||
msgType: 'io.element.effect.snowfall',
|
||||
command: 'snowfall',
|
||||
emojis: ["❄", "🌨"],
|
||||
msgType: "io.element.effect.snowfall",
|
||||
command: "snowfall",
|
||||
description: () => _td("Sends the given message with snowfall"),
|
||||
fallbackMessage: () => _t("sends snowfall") + " ❄",
|
||||
options: {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
import ICanvasEffect from '../ICanvasEffect';
|
||||
import ICanvasEffect from "../ICanvasEffect";
|
||||
import { arrayFastClone } from "../../utils/arrays";
|
||||
|
||||
export type RainfallOptions = {
|
||||
@@ -60,7 +60,7 @@ export default class Rainfall implements ICanvasEffect {
|
||||
if (!canvas) {
|
||||
return;
|
||||
}
|
||||
this.context = canvas.getContext('2d');
|
||||
this.context = canvas.getContext("2d");
|
||||
this.particles = [];
|
||||
const count = this.options.maxCount;
|
||||
while (this.particles.length < count) {
|
||||
@@ -81,8 +81,8 @@ export default class Rainfall implements ICanvasEffect {
|
||||
particle.x = Math.random() * width;
|
||||
particle.y = Math.random() * -height;
|
||||
particle.width = Math.random() * 1.5;
|
||||
particle.height = (particle.width * 15) + 4;
|
||||
particle.speed = (Math.random() * this.options.speed * 4/5) + this.options.speed;
|
||||
particle.height = particle.width * 15 + 4;
|
||||
particle.speed = (Math.random() * this.options.speed * 4) / 5 + this.options.speed;
|
||||
return particle;
|
||||
};
|
||||
|
||||
@@ -115,14 +115,14 @@ export default class Rainfall implements ICanvasEffect {
|
||||
this.context.save();
|
||||
this.context.beginPath();
|
||||
this.context.rect(particle.x, particle.y, particle.width, particle.height);
|
||||
this.context.fillStyle = '#5dadec'; // light blue
|
||||
this.context.fillStyle = "#5dadec"; // light blue
|
||||
this.context.fill();
|
||||
this.context.closePath();
|
||||
this.context.restore();
|
||||
|
||||
// Remove dead raindrops
|
||||
const maxBounds = height * 2;
|
||||
if (particle.y > (height + maxBounds)) {
|
||||
if (particle.y > height + maxBounds) {
|
||||
const idx = this.particles.indexOf(particle);
|
||||
this.particles.splice(idx, 1);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
import ICanvasEffect from '../ICanvasEffect';
|
||||
import ICanvasEffect from "../ICanvasEffect";
|
||||
import { arrayFastClone } from "../../utils/arrays";
|
||||
|
||||
export type SnowfallOptions = {
|
||||
@@ -65,7 +65,7 @@ export default class Snowfall implements ICanvasEffect {
|
||||
if (!canvas) {
|
||||
return;
|
||||
}
|
||||
this.context = canvas.getContext('2d');
|
||||
this.context = canvas.getContext("2d");
|
||||
this.particles = [];
|
||||
const count = this.options.maxCount;
|
||||
while (this.particles.length < count) {
|
||||
@@ -86,9 +86,9 @@ export default class Snowfall implements ICanvasEffect {
|
||||
particle.x = Math.random() * width;
|
||||
particle.y = Math.random() * -height;
|
||||
particle.xCol = particle.x;
|
||||
particle.diameter = (Math.random() * 7) + 4;
|
||||
particle.maximumDrift = (Math.random() * this.options.maxDrift) + 3.5;
|
||||
particle.gravity = this.options.gravity + (Math.random() * 6) + 4;
|
||||
particle.diameter = Math.random() * 7 + 4;
|
||||
particle.maximumDrift = Math.random() * this.options.maxDrift + 3.5;
|
||||
particle.gravity = this.options.gravity + Math.random() * 6 + 4;
|
||||
return particle;
|
||||
};
|
||||
|
||||
@@ -132,14 +132,14 @@ export default class Snowfall implements ICanvasEffect {
|
||||
this.context.save();
|
||||
this.context.beginPath();
|
||||
this.context.ellipse(particle.x, particle.y, radius, radius, 0, 0, 360);
|
||||
this.context.fillStyle = '#eaeaea'; // grey so it shows up on the light theme
|
||||
this.context.fillStyle = "#eaeaea"; // grey so it shows up on the light theme
|
||||
this.context.fill();
|
||||
this.context.closePath();
|
||||
this.context.restore();
|
||||
|
||||
// Remove any dead snowflakes
|
||||
const maxBounds = radius * 4; // make sure it's *really* off screen
|
||||
if (particle.y > (height + maxBounds)) {
|
||||
if (particle.y > height + maxBounds) {
|
||||
const idx = this.particles.indexOf(particle);
|
||||
this.particles.splice(idx, 1);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
import ICanvasEffect from '../ICanvasEffect';
|
||||
import ICanvasEffect from "../ICanvasEffect";
|
||||
import { arrayFastClone } from "../../utils/arrays";
|
||||
|
||||
export type SpaceInvadersOptions = {
|
||||
@@ -59,7 +59,7 @@ export default class SpaceInvaders implements ICanvasEffect {
|
||||
if (!canvas) {
|
||||
return;
|
||||
}
|
||||
this.context = canvas.getContext('2d');
|
||||
this.context = canvas.getContext("2d");
|
||||
this.particles = [];
|
||||
const count = this.options.maxCount;
|
||||
while (this.particles.length < count) {
|
||||
@@ -80,7 +80,7 @@ export default class SpaceInvaders implements ICanvasEffect {
|
||||
particle.x = Math.random() * width;
|
||||
particle.y = Math.random() * -height;
|
||||
particle.xCol = particle.x;
|
||||
particle.gravity = this.options.gravity + (Math.random() * 6) + 4;
|
||||
particle.gravity = this.options.gravity + Math.random() * 6 + 4;
|
||||
return particle;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user