{"version":3,"file":"calculateSpriteScale.cjs","sources":["../../../src/utils/calculateSpriteScale.ts"],"sourcesContent":["/**\n * Calculate the appropriate scale for a sprite to fit in a container while maintaining aspect ratio\n *\n * @param imageWidth - Width of the image\n * @param imageHeight - Height of the image\n * @param containerWidth - Width of the container\n * @param containerHeight - Height of the container\n * @returns Object containing scale value and baseScale for reference\n */\nexport const calculateSpriteScale = (\n    imageWidth: number,\n    imageHeight: number,\n    containerWidth: number,\n    containerHeight: number\n): { scale: number; baseScale: number } => {\n    // Ensure dimensions are valid numbers\n    if (!imageWidth || !imageHeight || !containerWidth || !containerHeight) {\n        console.warn(\"Invalid dimensions for sprite scaling, using fallback scale 1\");\n        return { scale: 1, baseScale: 1 };\n    }\n\n    // Calculate aspect ratios\n    const imageAspect = imageWidth / imageHeight;\n    const containerAspect = containerWidth / containerHeight;\n\n    let scale: number;\n\n    // Determine which dimension (width or height) is the constraint\n    if (imageAspect > containerAspect) {\n        // Image is wider relative to container, so height is the constraint\n        scale = containerHeight / imageHeight;\n    } else {\n        // Image is taller relative to container, so width is the constraint\n        scale = containerWidth / imageWidth;\n    }\n\n    // Add padding to prevent edge cases\n    scale = scale * 0.95; // 5% padding\n\n    // Log scale calculation\n    console.log(\n        `Scale calculation: Image (${imageWidth}x${imageHeight}), Container (${containerWidth}x${containerHeight}), Scale: ${scale}`\n    );\n\n    return {\n        scale,\n        baseScale: scale\n    };\n};"],"names":[],"mappings":";;AASO,MAAM,oBAAuB,GAAA,CAChC,UACA,EAAA,WAAA,EACA,gBACA,eACuC,KAAA;AAEvC,EAAA,IAAI,CAAC,UAAc,IAAA,CAAC,eAAe,CAAC,cAAA,IAAkB,CAAC,eAAiB,EAAA;AACpE,IAAA,OAAA,CAAQ,KAAK,+DAA+D,CAAA;AAC5E,IAAA,OAAO,EAAE,KAAA,EAAO,CAAG,EAAA,SAAA,EAAW,CAAE,EAAA;AAAA;AAIpC,EAAA,MAAM,cAAc,UAAa,GAAA,WAAA;AACjC,EAAA,MAAM,kBAAkB,cAAiB,GAAA,eAAA;AAEzC,EAAI,IAAA,KAAA;AAGJ,EAAA,IAAI,cAAc,eAAiB,EAAA;AAE/B,IAAA,KAAA,GAAQ,eAAkB,GAAA,WAAA;AAAA,GACvB,MAAA;AAEH,IAAA,KAAA,GAAQ,cAAiB,GAAA,UAAA;AAAA;AAI7B,EAAA,KAAA,GAAQ,KAAQ,GAAA,IAAA;AAGhB,EAAQ,OAAA,CAAA,GAAA;AAAA,IACJ,CAAA,0BAAA,EAA6B,UAAU,CAAI,CAAA,EAAA,WAAW,iBAAiB,cAAc,CAAA,CAAA,EAAI,eAAe,CAAA,UAAA,EAAa,KAAK,CAAA;AAAA,GAC9H;AAEA,EAAO,OAAA;AAAA,IACH,KAAA;AAAA,IACA,SAAW,EAAA;AAAA,GACf;AACJ;;;;"}