Update sprite positioning in PersonChatPortraits to enhance visual alignment

- Adjusted sprite positioning by shifting it 20% away from the direction the character is facing, improving the visual representation for both NPCs and players.
- Ensured consistent handling of sprite and image centering across the canvas for better overall aesthetics.
This commit is contained in:
Z. Cliffe Schreuders
2025-11-07 17:41:54 +00:00
parent 717221cb3c
commit 8315abc932

View File

@@ -272,9 +272,15 @@ export default class PersonChatPortraits {
// Calculate position to center the sprite
const scaledWidth = spriteWidth * scale;
const scaledHeight = spriteHeight * scale;
const x = (canvasWidth - scaledWidth) / 2;
let x = (canvasWidth - scaledWidth) / 2;
const y = (canvasHeight - scaledHeight) / 2;
// Shift sprite 20% away from the direction they're facing
// Shifting left works for both flipped and non-flipped due to coordinate transform
// NPCs (flipped) appear on right, Player (not flipped) appears on left
const shiftAmount = canvasWidth * 0.2;
x -= shiftAmount;
// Draw the sprite frame scaled to fill canvas with optional flip
this.ctx.imageSmoothingEnabled = false;
@@ -366,9 +372,15 @@ export default class PersonChatPortraits {
// Calculate position to center the image
const scaledWidth = imgWidth * scale;
const scaledHeight = imgHeight * scale;
const x = (canvasWidth - scaledWidth) / 2;
let x = (canvasWidth - scaledWidth) / 2;
const y = (canvasHeight - scaledHeight) / 2;
// Shift sprite 20% away from the direction they're facing
// Shifting left works for both flipped and non-flipped due to coordinate transform
// NPCs (flipped) appear on right, Player (not flipped) appears on left
const shiftAmount = canvasWidth * 0.2;
x -= shiftAmount;
// Draw image scaled to fill canvas with optional flip
this.ctx.imageSmoothingEnabled = false;