Function: snapToPixelGrid()
snapToPixelGrid(
x,y,width,height):PixelArea
Defined in: src/lib/brushes/params/index.ts:243
Move an area centred on a point onto whole pixels. The size is rounded to whole pixels and the top-left corner is rounded down, so the pixel under the point is always covered.
Parameters
x
number
y
number
width
number
height
number
Returns
Example
snapToPixelGrid(10.7, 4.2, 1, 1); // { x: 10.5, y: 4.5, width: 1, height: 1 }: the pixel at (10, 4)
snapToPixelGrid(10.7, 4.2, 2, 2); // { x: 10, y: 4, width: 2, height: 2 }: pixels 9–10 and 3–4