1
0
mirror of https://github.com/robonen/eulerian-cycle.git synced 2026-03-19 18:34:47 +00:00

Create node fix

This commit is contained in:
2021-12-28 20:54:09 +07:00
parent 3261064c5d
commit 66481d7f79
2 changed files with 14 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 MiB

View File

@@ -106,7 +106,7 @@ export default {
(stepId) => highlight(stepId)
);
// Methodsc
// Methods
const highlight = (stepId) => {
if (loop === null) return;
@@ -130,6 +130,15 @@ export default {
activateNodes([current.source, current.target]);
};
const hasntIntersections = (node) => {
return nodes.value.every((current) => {
return (
(RADIUS * 2) ** 2 <
(node.x - current.x) ** 2 + (node.y - current.y) ** 2
);
});
};
const loopPosition = (coords) => {
const node = nodes.value[coords];
@@ -185,8 +194,10 @@ export default {
selected: 0,
};
nodes.value.push(newNode);
emit("hasVertices", nodes.value.length);
if (hasntIntersections(newNode)) {
nodes.value.push(newNode);
emit("hasVertices", nodes.value.length);
}
};
const removeNode = (id) => {