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, startBoundingBox: Bounds,
endBoundingBox: Bounds, endBoundingBox: Bounds,
) => { ) => {
const width = aabb[2] - aabb[0]; return Math.min(
const height = aabb[3] - aabb[1]; Math.hypot(
const size = Math.max(width, height);
const startExtent = Math.max(
startBoundingBox[2] - startBoundingBox[0], startBoundingBox[2] - startBoundingBox[0],
startBoundingBox[3] - startBoundingBox[1], startBoundingBox[3] - startBoundingBox[1],
10, ) / 4,
); Math.hypot(
const endExtent = Math.max(
endBoundingBox[2] - endBoundingBox[0], endBoundingBox[2] - endBoundingBox[0],
endBoundingBox[3] - endBoundingBox[1], 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 = ( const handleSegmentRenormalization = (