Skip to content

Commit 4ff363f

Browse files
committed
going back to before
1 parent 57fe4d3 commit 4ff363f

2 files changed

Lines changed: 5 additions & 32 deletions

File tree

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ node_modules
1212
.DS_Store
1313
Thumbs.db
1414

15-
/.obsidian
16-
1715
# Env
1816
.env
1917
.env.*

static/canvas.js

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -214,36 +214,11 @@ function drawEdges() {
214214
const fromPoint = getAnchorPoint(fromNode, edge.fromSide);
215215
const toPoint = getAnchorPoint(toNode, edge.toSide);
216216

217-
// Calculate control point offset based on distance
218-
const dx = Math.abs(toPoint.x - fromPoint.x);
219-
const dy = Math.abs(toPoint.y - fromPoint.y);
220-
const offset = Math.max(dx, dy) * 0.5;
221-
222-
// Set control points based on edge sides for proper arrow direction
223-
let controlPointX1 = fromPoint.x;
224-
let controlPointY1 = fromPoint.y;
225-
let controlPointX2 = toPoint.x;
226-
let controlPointY2 = toPoint.y;
227-
228-
// First control point extends from the fromSide
229-
if (edge.fromSide === 'right') controlPointX1 += offset;
230-
else if (edge.fromSide === 'left') controlPointX1 -= offset;
231-
else if (edge.fromSide === 'bottom') controlPointY1 += offset;
232-
else if (edge.fromSide === 'top') controlPointY1 -= offset;
233-
234-
// Second control point: position to make arrow point in correct direction
235-
// For vertical arrows, keep X aligned; for horizontal arrows, keep Y aligned
236-
if (edge.toSide === 'right') {
237-
controlPointX2 -= offset; // CP left of endpoint → arrow points right
238-
} else if (edge.toSide === 'left') {
239-
controlPointX2 += offset; // CP right of endpoint → arrow points left
240-
} else if (edge.toSide === 'top') {
241-
controlPointX2 = toPoint.x; // Keep X aligned for vertical approach
242-
controlPointY2 -= offset; // CP above endpoint → arrow points down
243-
} else if (edge.toSide === 'bottom') {
244-
controlPointX2 = toPoint.x; // Keep X aligned for vertical approach
245-
controlPointY2 += offset; // CP below endpoint → arrow points up
246-
}
217+
const curveTightness = 0.75;
218+
const controlPointX1 = fromPoint.x + (toPoint.x - fromPoint.x) * curveTightness;
219+
const controlPointX2 = fromPoint.x + (toPoint.x - fromPoint.x) * (1 - curveTightness);
220+
const controlPointY1 = fromPoint.y;
221+
const controlPointY2 = toPoint.y;
247222

248223
const d = `M ${fromPoint.x} ${fromPoint.y} C ${controlPointX1} ${controlPointY1}, ${controlPointX2} ${controlPointY2}, ${toPoint.x} ${toPoint.y}`;
249224

0 commit comments

Comments
 (0)