mirror of
https://github.com/sotam0316/drawNET.git
synced 2026-04-25 03:58:37 +09:00
Initial commit: drawNET Alpha v1.0 - Professional Topology Designer with Full i18n and Performance Optimizations
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Snap a position to the nearest grid interval, accounting for the object's dimension
|
||||
* to ensure its edges or center align properly with the grid.
|
||||
*/
|
||||
export function snapPosition(pos, dimension, spacing) {
|
||||
const offset = (dimension / 2) % spacing;
|
||||
return Math.round((pos - offset) / spacing) * spacing + offset;
|
||||
}
|
||||
Reference in New Issue
Block a user