UNPKG

@tomiaa/live2d

Version:
36 lines (35 loc) 775 B
import { CONTAINER_WIDTH_RATIO as e } from "../constants.js"; class R { /** * 计算容器宽度 */ static calculateWidth(t, r) { let u = window.innerWidth * e; return u > t && (u = t), u < r && (u = r), u; } /** * 计算容器高度 */ static calculateHeight(t, r, u = [10, 9]) { const i = (r == null ? void 0 : r.aspectRatio) || u; return t / i[0] * i[1]; } /** * 计算模型缩放比例 */ static calculateModelScale(t, r, u, i) { return t > r ? u / t : i / r; } /** * 获取自定义缩放值 */ static getCustomScale(t) { return typeof t == "number" ? { x: t, y: t } : { x: (t == null ? void 0 : t.x) || 1, y: (t == null ? void 0 : t.y) || 1 }; } } export { R as ResizeHelper };