Function snapToPixel

  • Snap a value to a pixel depending on viewport size and zoom level. If viewport size is divisible by 2, the zoomed value will be snapped to integers. Otherwise the zoomed value will be snapped to .5 values instead.

    Parameters

    • value: number

      The value to snap.

    • viewportSize: number

      The viewport size.

    • zoom: number

      The zoom level of the camera.

    Returns number

    The adjusted value.