From 1257e5ac73216bb6f3331242ce56a7928a2e4094 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sat, 23 Mar 2024 21:12:22 -0400 Subject: [PATCH] Fix --- commands/edit-face/anime-eyes.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/commands/edit-face/anime-eyes.js b/commands/edit-face/anime-eyes.js index a9fe605e..dca94423 100644 --- a/commands/edit-face/anime-eyes.js +++ b/commands/edit-face/anime-eyes.js @@ -45,10 +45,14 @@ module.exports = class AnimeEyesCommand extends Command { for (const face of faces) { const eyeWidth = face.box.width / 5; const eyeHeight = face.box.height / 5; + const leftEyeX = leftEyeData.x - (eyeWidth / 2); + const leftEyeY = leftEyeData.y - (eyeHeight / 2); + const rightEyeX = rightEyeData.x - (eyeWidth / 2); + const rightEyeY = rightEyeData.y - (eyeHeight / 2); const leftEyeData = face.keypoints.find(landmark => landmark.name === 'leftEye'); - ctx.drawImage(rightEye, leftEyeData.x - eyeWidth, leftEyeData.y - eyeHeight, eyeWidth, eyeHeight); + ctx.drawImage(rightEye, leftEyeX, leftEyeY, eyeWidth, eyeHeight); const rightEyeData = face.keypoints.find(landmark => landmark.name === 'rightEye'); - ctx.drawImage(leftEye, rightEyeData.x - eyeWidth, rightEyeData.y - eyeHeight, eyeWidth, eyeHeight); + ctx.drawImage(leftEye, rightEyeX, rightEyeY, eyeWidth, eyeHeight); } return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'anime-eyes.png' }] }); }