मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग6.4k · #14200

melonjs-display-and-scaling

यह क्या करती है

यह उन सेटिंग को समझाती है जो melonJS गेम का स्क्रीन पर आकार और तीखापन तय करती हैं। यह उन डेवलपर्स के लिए है जिनका गेम नरम दिखता है या ब्राउज़र विंडो में ठीक से फ़िट नहीं होता।

कब इस्तेमाल करें

  • ✓जब melonJS गेम उच्च रिज़ॉल्यूशन स्क्रीन पर धुंधला या नरम दिखे।
  • ✓जब melonJS गेम कटा हुआ हो या पेज को उस तरह न भरे जैसा डेवलपर चाहता है।
  • ✓जब डेवलपर पिक्सल आर्ट के लिए ब्राउज़र गेम में पिक्सल-परफ़ेक्ट आकार चाहता हो।

Skill का लिंक

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

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-display-and-scaling/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरा melonJS पिक्सल आर्ट धुंधला है और विंडो में फ़िट नहीं होता। मुझे कौन सी सेटिंग बदलनी चाहिए?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह स्किल सेटिंग को उनके काम के हिसाब से बाँटती है, जैसे डिज़ाइन आकार, scaling तरीका, rounding और texture filtering, और हर समस्या के लिए बताती है कि कौन सी बदलनी है।

तकनीकी सामग्री (मूल 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

अक्सर पूछे जाने वाले सवाल

डिज़ाइन रिज़ॉल्यूशन क्या है?

यह वह तय आकार है जिस पर गेम बनाया जाता है, जिसे फिर विंडो में फ़िट करने के लिए scale किया जाता है।

पिक्सल आर्ट को तीखा कैसे रखूँ?

स्किल पूर्णांक scaling और nearest-neighbor texture filtering को सामान्य विकल्प बताती है।

गति असमान क्यों दिखती है?

स्किल फ़्रेम के बीच स्थिर गति के लिए एक sync सेटिंग का ज़िक्र करती है।

जानकारी

लेखक का मूल विवरण

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
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

melonjs-20-migration

6.4k

आपके एजेंट को melonJS वर्शन 20 के लिए गेम कोड लिखने में मदद करती है और पुराने वर्शन के आउटडेटेड तरीकों से बचाती है, जैसे ज़रूरी async स्टार्टअप।

कोडिंगसामान्य कोडिंग

melonjs-3d-assets

6.4k

आपके एजेंट को glTF, GLB और OBJ जैसे 3D मॉडल melonJS ब्राउज़र गेम में लोड करने में मदद करती है, scale और lighting विकल्पों के साथ।

कोडिंगसामान्य कोडिंग

melonjs-3d

6.4k

आपके एजेंट को melonJS ब्राउज़र गेम में 3D या 2.5D दृश्य बनाने में मदद करती है, जिसमें कैमरा, मेश, लाइट और गहराई शामिल हैं, इंजन के अपने axis नियमों के साथ।

कोडिंगसामान्य कोडिंग

melonjs-audio

6.4k

आपके एजेंट को melonJS गेम में साउंड इफ़ेक्ट और संगीत जोड़ने में मदद करती है, जिसमें ऑडियो सेटअप, बैकग्राउंड ट्रैक, वॉल्यूम नियंत्रण और स्थानिक ध्वनि शामिल हैं।

कोडिंगसामान्य कोडिंग

मिलती-जुलती skills