본문으로 건너뛰기
Skillpedia
일반 코딩6.4k · #14200

melonjs-display-and-scaling

하는 일

melonJS 게임의 크기와 선명도를 화면에서 조절하는 설정을 설명합니다. 게임이 흐리게 보이거나 브라우저 창에 맞지 않는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓고해상도 화면에서 melonJS 게임이 흐리거나 부드럽게 보일 때.
  • ✓melonJS 게임이 잘리거나 개발자가 원하는 방식으로 페이지를 채우지 않을 때.
  • ✓개발자가 브라우저 게임의 픽셀 아트를 위해 픽셀 단위로 정확한 크기를 원할 때.

스킬 링크

https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-display-and-scaling/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-display-and-scaling/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 melonJS 픽셀 아트가 흐리게 보이고 창에 맞지 않습니다. 어떤 설정을 바꿔야 하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

스킬은 설정을 디자인 크기, 확대·축소 방식, 반올림, 텍스처 필터링처럼 역할별로 나누고, 각 문제에 맞춰 무엇을 바꿔야 하는지 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Display and scaling

Seven settings decide how a game looks on screen, and they are easy to get individually right and collectively wrong. This is what each one actually does, and which one to reach for.

The four jobs

A pixel travels from your source art to a physical pixel through four separate decisions. Knowing which setting owns which is most of the work.

job setting what it decides
how big the frame is drawn width/height on Application the design resolution everything is authored against
how it uses the space scale, scaleMethod, scaleTarget fit, fill, stretch, and what it measures to decide
may the factor be fractional scaleRounding whole device pixels per source pixel, or any factor
how a texture is sampled antiAlias, textureFilter nearest or linear, and the CSS upscale filter

subPixel is a fifth, orthogonal to all of them: it decides whether a renderable may sit on a fractional position WITHIN the frame. syncToDisplay is about the frames in a row rather than one frame: whether motion advances by the same amount on each.

Design resolution

const app = new Application(480, 270, { scale: "auto" });

The game is drawn at 480x270 whatever the window is, and the canvas is scaled to the container. Everything in world coordinates is in those units. This is the usual arrangement: author once, scale to whatever you are given.

scale and scaleMethod

scale: "auto" turns on automatic scaling; a number is a fixed multiplier and scaleMethod is then ignored.

scaleMethod decides how the available space is used:

  • "fit" keeps the design resolution and the aspect ratio, scaling to the largest factor that fits. Leftover space becomes margin. This is the one to use when the game is authored for a fixed frame.
  • "fill-min" / "fill-max" keep the aspect ratio but RESIZE the renderer, so the design resolution changes with the window and the game sees more or less of the world.
  • "flex", "flex-width", "flex-height" resize the renderer on one or both axes.
  • "stretch" scales each axis independently, so the aspect ratio is not preserved and circles become ovals.
  • "manual" does nothing automatic.

The distinction that matters: fit scales a fixed frame; everything else changes how much of the world is visible. A game whose layout assumes a known frame wants fit.

scaleTarget: what gets measured

Automatic scaling measures the parent of the element the canvas is mounted in, not the element itself. If that grandparent is not the box you meant, the canvas is sized wrongly, and the failure is quiet.

The case that bites: a canvas container that is position: fixed or absolute contributes no height to its parent, so the parent measures only whatever else is in it. If that parent is <body>, the engine falls back to the window size and the canvas ends up larger than the box it lives in, cropped by whatever sits above it.

new Application(1024, 576, {
	parent: "screen",
	scale: "auto",
	// measure THIS, rather than guessing from the DOM shape
	scaleTarget: document.getElementById("stage"),
});

Either name the element with scaleTarget, or give the canvas container a parent whose box is the area you want filled. If the canvas is cropped or overflows on resize, this is the first thing to check.

scaleRounding: whole device pixels

new Application(480, 270, {
	scale: "auto",
	scaleMethod: "fit",
	scaleRounding: "integer",   // default "fractional"
});

"fractional" fills the container exactly, at whatever factor that takes. A 480 wide design in a 1280 wide container is scaled by 2.667, so some source pixels cover three screen pixels and some cover two. Pixel art shows this as uneven glyph stems and shimmering edges, and browsers resolve the unevenness differently, so the same scene can look crisp in one and soft in another.

"integer" rounds the factor DOWN so every source pixel covers the same whole number of device pixels, and letterboxes with the space left over. That trade, crisp pixels for black bars, is the whole decision.

What it costs

More than "some letterboxing", and the size of it is decided by devicePixelRatio as much as by the window. A higher ratio has more device pixels to round among, so it lands closer to the factor it wanted. For a 480x270 design, which is exactly a quarter of 1920x1080:

| container | ratio | f

자주 묻는 질문

디자인 해상도란 무엇인가요?

게임이 그려지는 고정 크기이며, 이것이 창에 맞게 확대·축소됩니다.

픽셀 아트를 선명하게 만들려면 어떻게 하나요?

정수 배율과 nearest-neighbor 텍스처 필터링을 일반적인 선택으로 언급합니다.

움직임이 고르지 않게 보이는 이유는 무엇인가요?

프레임 사이의 움직임을 일정하게 만드는 동기화 설정을 언급합니다.

상세 정보

작성자의 원본 설명

Use this skill when a melonJS game looks blurry, soft, shimmering or cropped, or when choosing how the canvas fills its page. Covers the design resolution, scale and scaleMethod, scaleTarget, scaleRounding for pixel-perfect integer scaling, antiAlias, textureFilter and linear-mipmap for what is drawn small, subPixel, syncToDisplay for steady motion, devicePixelRatio, and which setting does which job. Triggers on: blurry, soft, fuzzy, shimmering, pixel art, pixel perfect, crisp, nearest, linear, scale, scaleMethod, scaleTarget, scaleRounding, integer scaling, antiAlias, textureFilter, linear-mi

repo: melonjs/melonJS

인기도

GitHub 스타
6.4k
순위
#14200
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬