Skip to content
Product and web UIguide

How to draw a sharp icon on a high-density canvas

By SkeuDesign Editorial Team1 min read

Answer in brief

Allocate a larger canvas backing store for high-density displays and scale the drawing context so your drawing instructions can stay in CSS-pixel units.

Check a 40-pixel stamp

On a device pixel ratio of 2, give a 40-by-40 CSS pixel canvas an 80-by-80 backing store. Scale the context by 2 and draw into a 40-unit square using sufficiently detailed source art. Reset transforms when resizing.

Avoid scaling twice after a resize

Changing a canvas dimension resets its drawing context. Reinitialize its coordinate transform after setting both bitmap dimensions. If your resize handler also runs without changing those dimensions, use an absolute transform or reset the transform first. A stamp that doubles on every resize usually indicates accumulated transforms.

Sources

  1. [1] Window: devicePixelRatio property - Web APIs — MDN Web Docs, accessed November 23, 2026

Frequently asked questions

Does a larger backing store add missing source detail?

It improves rendering resolution. A tiny raster source may still look soft after enlargement.