mirror of
https://github.com/robonen/eulerian-cycle.git
synced 2026-03-20 02:44: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)
|
(stepId) => highlight(stepId)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Methodsc
|
// Methods
|
||||||
const highlight = (stepId) => {
|
const highlight = (stepId) => {
|
||||||
if (loop === null) return;
|
if (loop === null) return;
|
||||||
|
|
||||||
@@ -130,6 +130,15 @@ export default {
|
|||||||
activateNodes([current.source, current.target]);
|
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 loopPosition = (coords) => {
|
||||||
const node = nodes.value[coords];
|
const node = nodes.value[coords];
|
||||||
|
|
||||||
@@ -185,8 +194,10 @@ export default {
|
|||||||
selected: 0,
|
selected: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (hasntIntersections(newNode)) {
|
||||||
nodes.value.push(newNode);
|
nodes.value.push(newNode);
|
||||||
emit("hasVertices", nodes.value.length);
|
emit("hasVertices", nodes.value.length);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeNode = (id) => {
|
const removeNode = (id) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user