Pixel art rendering and sprite conventions for web games. Choosing a base resolution and sprite sizes, integer scaling and letterboxing, nearest-neighbor filtering everywhere (canvas, CSS, WebGL, Phaser, Pixi, three.js), rounding positions and the camera, avoiding blur, seams and shimmering, palettes, outlines and readability, animation frame counts, pixel fonts, UI at the same pixel scale, and...
Download skill (.zip) Files on GitHubPixel art development
1. Pick a base resolution (render at it, scale up)
| Base | Feel | Sprites |
|---|---|---|
| 320×180 | Chunky, retro | 16×16 |
| 384×216 / 426×240 | Classic 16-bit | 16–32 |
| 480×270 / 640×360 | Detailed | 32×32 |
16:9 bases scale by whole numbers to 1280×720 (×4 from 320×180), 1920×1080 (×6) and phones.
2. Crisp rendering, everywhere
// draw the game into a small canvas at base resolution, then scale the whole canvas
const low = document.createElement("canvas"); low.width = 320; low.height = 180;
const g = low.getContext("2d"); g.imageSmoothingEnabled = false; // re-set after any resize
function present() {
const scale = Math.max(1, Math.floor(Math.min(innerWidth / 320, innerHeight / 180))); // integer scale
view.width = 320 * scale; view.height = 180 * scale; // (or CSS size with image-rendering: pixelated)
const v = view.getContext("2d"); v.imageSmoothingEnabled = false; v.drawImage(low, 0, 0, view.width, view.height);
}
CSS: canvas { image-rendering: pixelated; }. Phaser: pixelArt: true, roundPixels: true. Pixi: TextureStyle.defaultOptions.scaleMode = "nearest"
and roundPixels: true. three.js: texture.magFilter = texture.minFilter = THREE.NearestFilter.
If integer scaling leaves big borders on phones, allow non-integer scaling for the final blit only (the low-res canvas stays crisp but pixels become slightly uneven), or use the “expand” approach (responsive-game-design) to show more world.
3. No shimmer, no seams
- Round positions at draw time (
Math.round(x - cam.left)), keep the simulation in floats. - Camera: round its final offset (camera-system
pixelSnap: true). - Tiles: tileset with 1-px extruded padding (or spacing) to avoid bleeding; draw tilemaps at integer offsets.
- No rotation or sub-pixel scaling of sprites (pre-draw rotated frames, or accept the look).
4. Art conventions
- A limited palette (e.g. 16–32 colors; Lospec has many) used across sprites, tiles and UI.
- 1-px dark outlines (not pure black) for characters so they read on any background.
- Characters readable as silhouettes; key colors for the player vs. enemies.
- Animation: few frames, strong poses (idle 2–4, run 6–8, attack 3–5) (sprite-animation).
- UI and text at the same pixel scale with a pixel font (e.g. a CC0/OFL font at its native size × scale). Don’t mix sizes.
5. Making art
Aseprite (paid), LibreSprite / Piskel (free). Free packs: Kenney (CC0), OpenGameArt (check licenses; credit in CREDITS.md).
Placeholder art: colored rectangles at the final sprite size, so swapping is painless.