Skip to content

1681-engine / ui / snapPx

Function: snapPx() ​

ts
function snapPx(v, on?): number;

Defined in: src/ui/layout/geometry.ts:36

Rounds to a whole pixel when on. Pixel art laid out at x.5 lands each texel across two screen pixels and reads blurred or a pixel wider on one side, so a pixel-perfect game snaps every UI position and size.

Parameters ​

ParameterTypeDefault value
vnumberundefined
onbooleantrue

Returns ​

number

Released under the MIT License.