Project

General

Profile

Actions

Improvement #1806

open

Make getGridDistance() smarter

Added by Axel "Elanis" Soupé 15 days ago. Updated 7 days ago.

Status:
Pending
Priority:
Normal
Assignee:
-
Target version:
Start date:
10/03/2024
Due date:
% Done:

0%

Estimated time:
Story points:
8
Actions #1

Updated by Axel "Elanis" Soupé 7 days ago

function getIOPositions(origin, destination) {
const originX1 = origin.x;
const originX2 = origin.x + origin.width;
const destinationX1 = destination.x;
const destinationX2 = destination.x + destination.width;

let originIO = {
	x: originX1,
	y: origin.y + origin.height / 2,
};
if(Math.abs(originX1 - destinationX1) > Math.abs(originX2 - destinationX1)) {
	originIO.x = originX2;
}

let destinationIO = {
	x: destinationX1,
	y: destination.y + destination.height / 2,
};
if(Math.abs(originX1 - destinationX1) > Math.abs(originX1 - destinationX2)) {
	destinationIO.x = destinationX2;
}

return {
	origin: originIO,
	destination: destinationIO,
};

}

Actions

Also available in: Atom PDF