Skip to content

Function: snapToDevicePixel() ​

ts
function snapToDevicePixel(px, pixelRatio, phase?): number;

Experimental

Snap a CSS-pixel coordinate to the device-pixel grid (phase 0 = pixel edges, 0.5 = pixel centers). CPU mirror of hcSnap in SCREEN_GLSL, used by tests.

Parameters ​

ParameterTypeDefault value
pxnumberundefined
pixelRationumberundefined
phasenumber0

Returns ​

number

Released under the MIT License.