snap_to_grid¶
- emlib.misc.snap_to_grid(x, tick, offset=0, nearest=True)[source]¶
Find the nearest slot in a grid
Given a grid defined by offset + tick * N, find the nearest element of that grid to a given x :rtype:
Union
[float
,Rational
]Note
the result will have the same type as x, so if x is float, the result will be float, if it is a Fraction, then the result will be a fraction