Extend luggage tag thread lead-in
This commit is contained in:
@@ -55,6 +55,7 @@ describe('red thread geometry', () => {
|
|||||||
it('draws a short foreground thread segment into the eyelet from the visual left', () => {
|
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)
|
const leftToRight = threadTagLeadIn({ x: 0, y: 0 }, { x: 200, y: 0 }, 100, 50)
|
||||||
expect(leftToRight.start.x).toBeLessThan(leftToRight.end.x)
|
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.end).toEqual({ x: 100, y: 0 })
|
||||||
expect(leftToRight.path).toMatch(/^M .* C .* 100 0$/)
|
expect(leftToRight.path).toMatch(/^M .* C .* 100 0$/)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ export function threadTagLeadIn(from: BoardPoint, to: BoardPoint, tightness = 65
|
|||||||
const tagT = position / 100
|
const tagT = position / 100
|
||||||
const tangent = cubicTangent(from, c1, c2, to, tagT)
|
const tangent = cubicTangent(from, c1, c2, to, tagT)
|
||||||
const speed = Math.max(1, Math.hypot(tangent.x, tangent.y))
|
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 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 [start, leadC1, leadC2] = cubicSegment([from, c1, c2, to], entryT, tagT)
|
||||||
const end = cubicPoint(from, c1, c2, to, tagT)
|
const end = cubicPoint(from, c1, c2, to, tagT)
|
||||||
|
|||||||
Reference in New Issue
Block a user