Another algo forpaddings

This commit is contained in:
Mark Tolmacs 2025-04-28 19:31:30 +02:00
parent e6ade3b627
commit 7d0d6aec7a
No known key found for this signature in database

View file

@ -116,25 +116,18 @@ const calculatePadding = (
startBoundingBox: Bounds,
endBoundingBox: Bounds,
) => {
const width = aabb[2] - aabb[0];
const height = aabb[3] - aabb[1];
const size = Math.max(width, height);
const startExtent = Math.max(
return Math.min(
Math.hypot(
startBoundingBox[2] - startBoundingBox[0],
startBoundingBox[3] - startBoundingBox[1],
10,
);
const endExtent = Math.max(
) / 4,
Math.hypot(
endBoundingBox[2] - endBoundingBox[0],
endBoundingBox[3] - endBoundingBox[1],
10,
) / 4,
Math.hypot(aabb[2] - aabb[0], aabb[3] - aabb[1]) / 4,
40,
);
return Math.min(startExtent, endExtent) < 80
? Math.min(startExtent, endExtent) / 2
: size > 75
? 40
: Math.min(Math.max(Math.min(width / 2 - 1, height / 2 - 1), 10), 40);
};
const handleSegmentRenormalization = (