Added brush grid snapping
This commit is contained in:
@@ -23,3 +23,14 @@ export function fromEntries(iterable) {
|
||||
export function isStreamStopped(stream) {
|
||||
return stream.getTracks().reduce((a, b) => a && b, { mute: true });
|
||||
}
|
||||
|
||||
export function roundTo(x, to) {
|
||||
return Math.round(x / to) * to;
|
||||
}
|
||||
|
||||
export function snapPositionToGrid(position, gridSize) {
|
||||
return {
|
||||
x: roundTo(position.x, gridSize.x),
|
||||
y: roundTo(position.y, gridSize.y),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user