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:
BIN
public/air.bmp
BIN
public/air.bmp
Binary file not shown.
|
Before Width: | Height: | Size: 14 MiB |
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user