Skip to content

feat(pip): PiP ウィンドウのサイズを Canvas のアスペクト比に合わせる - #19

Draft
lollipop-onl wants to merge 1 commit into
developfrom
claude/pip-canvas-sizing-k0gdvl
Draft

feat(pip): PiP ウィンドウのサイズを Canvas のアスペクト比に合わせる#19
lollipop-onl wants to merge 1 commit into
developfrom
claude/pip-canvas-sizing-k0gdvl

Conversation

@lollipop-onl

Copy link
Copy Markdown
Member

概要

Document Picture-in-Picture API の requestWindow() に渡すサイズが 360x270(4:3)固定だったため、16:9 のシャニマスの Canvas を表示すると上下に黒帯が出ていました。Canvas のアスペクト比からウィンドウサイズを計算するように変更します。

変更内容

entrypoints/background/pip.ts

const aspectRatio =
  canvas.width > 0 && canvas.height > 0 ? canvas.width / canvas.height : 16 / 9;
const maxWidth = Math.max(480, Math.round(window.screen.availWidth / 3));
const maxHeight = Math.max(270, Math.round(window.screen.availHeight / 3));
const width = Math.round(Math.min(maxWidth, maxHeight * aspectRatio));
const height = Math.round(width / aspectRatio);
  • 比率はハードコードせず Canvas の実サイズから算出(サイズが 0 のときのみ 16:9 にフォールバック)
  • 画面のおよそ 1/3 を目安にしつつ、maxHeight * aspectRatio で縦方向にも収まるように抑制。1920x1080 のディスプレイなら 640x360
  • 下限は 480x270。小さい画面でもウィンドウが潰れないように

Document PiP 非対応環境での video.requestPictureInPicture() へのフォールバックは変更していません。

確認事項

  • pnpm build が通ることを確認済み
  • Biome の format / lint 済み(pre-commit フックも通過)
  • ブラウザでの実表示は未確認です

Generated by Claude Code

Compute the Document Picture-in-Picture window size from the game
canvas aspect ratio (16:9) instead of the fixed 360x270 (4:3), so the
video fills the window without letterboxing. The size targets roughly a
third of the available screen, with a 480x270 floor.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011sUVjio9hRnfXVfpZBwKrn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants