Commit 7f4f57a5 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: preserve aspect ratio for Ludo pawn sprites on canvas

Use Math.min() scaling (same approach as chess pieces) instead of
forcing sprites into a square bounding box which stretched non-square
pawn images uploaded via admin branding.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 95d81235
......@@ -1115,7 +1115,12 @@ function drawPieces(cs) {
const pColor = COLORS[bSlot2];
if (spriteImg) {
const size = r * 2;
ctx.drawImage(spriteImg, ox - size/2, drawY - size/2, size, size);
const iw = spriteImg.naturalWidth || spriteImg.width;
const ih = spriteImg.naturalHeight || spriteImg.height;
const scale = Math.min(size / iw, size / ih);
const dw = iw * scale;
const dh = ih * scale;
ctx.drawImage(spriteImg, ox - dw/2, drawY - dh/2, dw, dh);
} else {
ctx.beginPath(); ctx.arc(ox, drawY - r*0.15, r*0.65, 0, Math.PI*2); ctx.fillStyle = pColor; ctx.fill();
ctx.beginPath(); ctx.ellipse(ox, drawY + r*0.4, r*0.8, r*0.4, 0, 0, Math.PI*2); ctx.fillStyle = pColor; ctx.fill();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment