Skip to content
TypeScript
414 B
Raw Blame
export function fitDeviceFrame(aspect: number, width: number, height: number, rightInset: number) {
  const availableWidth = Math.max(0, width - rightInset);
  if (availableWidth === 0 || height === 0) return { width: 0, height: 0 };
  const byHeight = { width: height * aspect, height };
  return byHeight.width <= availableWidth
    ? byHeight
    : { width: availableWidth, height: availableWidth / aspect };
}