Extend luggage tag thread lead-in

This commit is contained in:
2026-08-23 23:33:15 +02:00
parent 5987bf6444
commit 761c6a4d64
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -55,6 +55,7 @@ describe('red thread geometry', () => {
it('draws a short foreground thread segment into the eyelet from the visual left', () => {
const leftToRight = threadTagLeadIn({ x: 0, y: 0 }, { x: 200, y: 0 }, 100, 50)
expect(leftToRight.start.x).toBeLessThan(leftToRight.end.x)
expect(leftToRight.end.x - leftToRight.start.x).toBeCloseTo(54)
expect(leftToRight.end).toEqual({ x: 100, y: 0 })
expect(leftToRight.path).toMatch(/^M .* C .* 100 0$/)
+1 -1
View File
@@ -99,7 +99,7 @@ export function threadTagLeadIn(from: BoardPoint, to: BoardPoint, tightness = 65
const tagT = position / 100
const tangent = cubicTangent(from, c1, c2, to, tagT)
const speed = Math.max(1, Math.hypot(tangent.x, tangent.y))
const leadLength = Math.max(.035, Math.min(.18, 42 / speed))
const leadLength = Math.max(.0525, Math.min(.27, 63 / speed))
const entryT = Math.max(0, Math.min(1, tagT + (tangent.x < 0 ? leadLength : -leadLength)))
const [start, leadC1, leadC2] = cubicSegment([from, c1, c2, to], entryT, tagT)
const end = cubicPoint(from, c1, c2, to, tagT)