Improved snapping
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Tue, 16 Jul 2019 11:39:49 +0000 (13:39 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Tue, 16 Jul 2019 11:39:49 +0000 (13:39 +0200)
net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/Editor.java

index 945490c..e327915 100644 (file)
@@ -192,8 +192,8 @@ public final class Editor
                case OFF:
                        break;
                case ABSOLUTE:
-                       newP.x -= newP.x % snapX;
-                       newP.y -= newP.y % snapY;
+                       newP.x = (int) (newP.x / snapX + .5) * snapX;
+                       newP.y = (int) (newP.y / snapY + .5) * snapY;
                        break;
                default:
                        break;