mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Fix
This commit is contained in:
@@ -45,10 +45,14 @@ module.exports = class AnimeEyesCommand extends Command {
|
|||||||
for (const face of faces) {
|
for (const face of faces) {
|
||||||
const eyeWidth = face.box.width / 5;
|
const eyeWidth = face.box.width / 5;
|
||||||
const eyeHeight = face.box.height / 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');
|
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');
|
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' }] });
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'anime-eyes.png' }] });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user