Squish in pet

This commit is contained in:
Dragon Fire
2021-01-09 15:53:50 -05:00
parent cf2dd37d1b
commit a0052cc3fc
2 changed files with 5 additions and 2 deletions
+4 -1
View File
@@ -43,14 +43,17 @@ module.exports = class PetCommand extends Command {
encoder.setDelay(20); encoder.setDelay(20);
encoder.setQuality(200); encoder.setQuality(200);
encoder.setTransparent('#000000'); encoder.setTransparent('#000000');
let squish = 0;
for (let i = 0; i < frameCount; i++) { for (let i = 0; i < frameCount; i++) {
const frameID = `frame_${i.toString().padStart(2, '0')}.png`; const frameID = `frame_${i.toString().padStart(2, '0')}.png`;
const frame = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'pet', frameID)); const frame = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'pet', frameID));
const { x, y, width, height } = centerImagePart(data, 75, 75, 27, 38); const { x, y, width, height } = centerImagePart(data, 75, 75, 27, 38);
ctx.drawImage(data, x, y, width, height); ctx.drawImage(data, x, y + squish, width, height - squish);
ctx.drawImage(frame, 0, 0); ctx.drawImage(frame, 0, 0);
encoder.addFrame(ctx); encoder.addFrame(ctx);
ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.clearRect(0, 0, canvas.width, canvas.height);
if (i + 1 > frameCount / 2) squish -= 3;
else squish += 3;
} }
encoder.finish(); encoder.finish();
const buffer = await streamToArray(stream); const buffer = await streamToArray(stream);
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xiao", "name": "xiao",
"version": "124.5.3", "version": "124.5.4",
"description": "Your personal server companion.", "description": "Your personal server companion.",
"main": "Xiao.js", "main": "Xiao.js",
"scripts": { "scripts": {