Hat Scaling

This commit is contained in:
Dragon Fire
2020-04-02 15:51:30 -04:00
parent fae5e977c3
commit c25ce78122
2 changed files with 12 additions and 3 deletions
+11 -2
View File
@@ -116,12 +116,21 @@ module.exports = class HatCommand extends Command {
prompt: 'How far do you want to move the hat on the Y-Axis?',
type: 'integer',
default: 0
},
{
key: 'scale',
prompt: 'By what percentage do you want to scale your hat?',
type: 'integer',
min: 0,
max: 100,
default: 0
}
]
});
}
async run(msg, { type, user, addX, addY }) {
async run(msg, { type, user, addX, addY, scale }) {
scale /= 100;
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
try {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'hat', `${type}.png`));
@@ -130,7 +139,7 @@ module.exports = class HatCommand extends Command {
const canvas = createCanvas(avatar.width, avatar.height);
const ctx = canvas.getContext('2d');
ctx.drawImage(avatar, 0, 0);
ctx.drawImage(base, 0 + addX, 0 + addY, avatar.width, avatar.height);
ctx.drawImage(base, 0 + addX, 0 + addY, avatar.width * scale, avatar.height * scale);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: `${type}-hat.png` }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "112.19.7",
"version": "112.19.8",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {