Compare commits
No commits in common. "ff01f9a4b5dfc7682ab7d491ee333fdb7c803b88" and "e995e4134b63b5b59a285a76fe2b68dd5202940c" have entirely different histories.
ff01f9a4b5
...
e995e4134b
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "misskey",
|
"name": "misskey",
|
||||||
"version": "12.100.2+birb2",
|
"version": "12.100.2+birb1",
|
||||||
"codename": "indigo",
|
"codename": "indigo",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 322 B |
|
@ -11,28 +11,8 @@
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
|
|
||||||
const randomColor = () => '#' + ('000000' + Math.floor(Math.random() * 16777215).toString(16)).slice(-6);
|
const sprite = new Image();
|
||||||
const sprites = {
|
sprite.src = '/client-assets/sparkle-spritesheet.png';
|
||||||
christmas: {
|
|
||||||
src: '/client-assets/snowflake-sprite.png',
|
|
||||||
size: 39,
|
|
||||||
color: () => {
|
|
||||||
const colors = ['#4cb1de', '#409feb', '#12536c'];
|
|
||||||
return colors[Math.floor(Math.random() * colors.length)];
|
|
||||||
},
|
|
||||||
},
|
|
||||||
default: {
|
|
||||||
src: '/client-assets/sparkle-spritesheet.png',
|
|
||||||
size: 7,
|
|
||||||
sheet: [0, 6, 13, 20],
|
|
||||||
color: randomColor,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Months are zero indexed, but dates are not! I know, wild
|
|
||||||
const events = {
|
|
||||||
christmas: (date) => date.getMonth() === 11 && (date.getDate() === 24 || date.getDate() === 25),
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
|
@ -47,10 +27,10 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
sprites: [0,6,13,20],
|
||||||
particles: [],
|
particles: [],
|
||||||
anim: null,
|
anim: null,
|
||||||
ctx: null,
|
ctx: null,
|
||||||
sprite: null,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
unmounted() {
|
unmounted() {
|
||||||
|
@ -59,15 +39,6 @@ export default defineComponent({
|
||||||
mounted() {
|
mounted() {
|
||||||
this.ctx = this.$refs.canvas.getContext('2d');
|
this.ctx = this.$refs.canvas.getContext('2d');
|
||||||
|
|
||||||
const now = new Date();
|
|
||||||
const variant = Object.keys(events).find((event) => events[event](now));
|
|
||||||
|
|
||||||
this.sprite = sprites[variant ?? 'default'];
|
|
||||||
if (!this.sprite.image) {
|
|
||||||
this.sprite.image = new Image();
|
|
||||||
this.sprite.image.src = this.sprite.src;
|
|
||||||
}
|
|
||||||
|
|
||||||
new ResizeObserver(this.resize).observe(this.$refs.content);
|
new ResizeObserver(this.resize).observe(this.$refs.content);
|
||||||
|
|
||||||
this.resize();
|
this.resize();
|
||||||
|
@ -81,19 +52,15 @@ export default defineComponent({
|
||||||
const holder = [];
|
const holder = [];
|
||||||
|
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
let offset = null;
|
|
||||||
if (this.sprite.sheet) {
|
|
||||||
offset = this.sprite.sheet[Math.floor(Math.random() * this.sprite.sheet.length)];
|
|
||||||
}
|
|
||||||
|
|
||||||
const color = this.sprite.color(i);
|
const color = '#' + ('000000' + Math.floor(Math.random() * 16777215).toString(16)).slice(-6);
|
||||||
|
|
||||||
holder[i] = {
|
holder[i] = {
|
||||||
position: {
|
position: {
|
||||||
x: Math.floor(Math.random() * w),
|
x: Math.floor(Math.random() * w),
|
||||||
y: Math.floor(Math.random() * h)
|
y: Math.floor(Math.random() * h)
|
||||||
},
|
},
|
||||||
offset: offset,
|
style: this.sprites[ Math.floor(Math.random() * 4) ],
|
||||||
delta: {
|
delta: {
|
||||||
x: Math.floor(Math.random() * 1000) - 500,
|
x: Math.floor(Math.random() * 1000) - 500,
|
||||||
y: Math.floor(Math.random() * 1000) - 500
|
y: Math.floor(Math.random() * 1000) - 500
|
||||||
|
@ -101,6 +68,7 @@ export default defineComponent({
|
||||||
color: color,
|
color: color,
|
||||||
opacity: Math.random(),
|
opacity: Math.random(),
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return holder;
|
return holder;
|
||||||
|
@ -111,19 +79,15 @@ export default defineComponent({
|
||||||
|
|
||||||
const particleSize = Math.floor(this.fontSize / 2);
|
const particleSize = Math.floor(this.fontSize / 2);
|
||||||
this.particles.forEach((particle) => {
|
this.particles.forEach((particle) => {
|
||||||
var modulus = this.sprite.speed ?? Math.floor(Math.random() * 7);
|
var modulus = Math.floor(Math.random()*7);
|
||||||
if (this.sprite.sheet && Math.floor(time) % modulus === 0) {
|
|
||||||
if (this.sprite.sequential) {
|
if (Math.floor(time) % modulus === 0) {
|
||||||
const currentFrame = this.sprite.sheet.indexOf(particle.offset);
|
particle.style = this.sprites[ Math.floor(Math.random()*4) ];
|
||||||
particle.offset = this.sprite.sheet[(currentFrame + 1) % this.sprite.sheet.length];
|
|
||||||
} else {
|
|
||||||
particle.offset = this.sprite.sheet[Math.floor(Math.random() * this.sprite.sheet.length)];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ctx.save();
|
this.ctx.save();
|
||||||
this.ctx.globalAlpha = particle.opacity;
|
this.ctx.globalAlpha = particle.opacity;
|
||||||
const { image, size } = this.sprite;
|
this.ctx.drawImage(sprite, particle.style, 0, 7, 7, particle.position.x, particle.position.y, particleSize, particleSize);
|
||||||
this.ctx.drawImage(image, particle.offset ?? 0, 0, size, size, particle.position.x, particle.position.y, particleSize, particleSize);
|
|
||||||
|
|
||||||
this.ctx.globalCompositeOperation = "source-atop";
|
this.ctx.globalCompositeOperation = "source-atop";
|
||||||
this.ctx.globalAlpha = 0.5;
|
this.ctx.globalAlpha = 0.5;
|
||||||
|
@ -139,8 +103,6 @@ export default defineComponent({
|
||||||
if (!this.$refs.canvas) {
|
if (!this.$refs.canvas) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const particleSize = Math.floor(this.fontSize / 2);
|
|
||||||
this.particles.forEach((particle) => {
|
this.particles.forEach((particle) => {
|
||||||
if (!particle) {
|
if (!particle) {
|
||||||
return;
|
return;
|
||||||
|
@ -157,15 +119,15 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
if( particle.position.x > this.$refs.canvas.width ) {
|
if( particle.position.x > this.$refs.canvas.width ) {
|
||||||
particle.position.x = -particleSize;
|
particle.position.x = -7;
|
||||||
} else if (particle.position.x < -particleSize) {
|
} else if (particle.position.x < -7) {
|
||||||
particle.position.x = this.$refs.canvas.width;
|
particle.position.x = this.$refs.canvas.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (particle.position.y > this.$refs.canvas.height) {
|
if (particle.position.y > this.$refs.canvas.height) {
|
||||||
particle.position.y = -particleSize;
|
particle.position.y = -7;
|
||||||
particle.position.x = Math.floor(Math.random() * this.$refs.canvas.width);
|
particle.position.x = Math.floor(Math.random() * this.$refs.canvas.width);
|
||||||
} else if (particle.position.y < -particleSize) {
|
} else if (particle.position.y < -7) {
|
||||||
particle.position.y = this.$refs.canvas.height;
|
particle.position.y = this.$refs.canvas.height;
|
||||||
particle.position.x = Math.floor(Math.random() * this.$refs.canvas.width);
|
particle.position.x = Math.floor(Math.random() * this.$refs.canvas.width);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue