Skip to content

Documentation / @debuffjp/core / ScaleMode

Type Alias: ScaleMode ​

ScaleMode = "fit" | "integer" | "expand" | "pixel" | "none"

Defined in: core/src/game.ts:32

How the logical resolution maps onto the page:

  • fit: scale to fill the container, preserving aspect ratio (letterboxed).
  • integer: like fit but only whole-number scales, for crisp pixel art.
  • expand: like fit, but instead of letterboxing, the logical size grows along the spare axis to fill the container. width/height are the minimum; game.width/game.height change on resize (see hooks.resize), so lay out from them each frame. For responsive games: portrait on phones, landscape on desktop.
  • pixel: each logical unit is pixelSize CSS pixels (snapped to whole device pixels), and the logical size grows with the container in both directions, so a bigger window or monitor shows more of the game rather than bigger pixels. width/height are the minimum: a container too small for them at pixelSize scales down by whole device pixels instead, and one too small even at one device pixel per unit scales down by a fraction to fit, like fit (pixels aren't crisp then). Before 0.29.3 it stopped at one device pixel per unit, so the canvas overflowed the container. Like expand, lay out from game.width/game.height each frame.
  • none: canvas stays at its logical size in CSS pixels.