Fix line handles (#1904)
closes https://github.com/tldraw/brivate/issues/2876 ### Change Type - [x] `patch` — Bug fix - [ ] `minor` — New feature - [ ] `major` — Breaking change - [ ] `dependencies` — Changes to package dependencies[^1] - [ ] `documentation` — Changes to the documentation only[^2] - [ ] `tests` — Changes to any test code only[^2] - [ ] `internal` — Any other changes that don't affect the published package[^2] - [ ] I don't know [^1]: publishes a `patch` release, for devDependencies use `internal` [^2]: will not publish a new version ### Test Plan 1. Add a step-by-step description of how to test your PR here. 2. - [ ] Unit Tests - [ ] End to end tests ### Release Notes - Fixes an issue where line handles were slightly offset from the indicator line.
This commit is contained in:
parent
d9ce936ed0
commit
d059183586
1 changed files with 3 additions and 6 deletions
|
@ -83,7 +83,6 @@ export function getRoundedPolygonPoints(
|
|||
/** @public */
|
||||
export function getDrawLinePathData(id: string, outline: VecLike[], strokeWidth: number) {
|
||||
let innerPathData = `M ${precise(outline[0])}L`
|
||||
let outerPathData1 = `M ${precise(outline[0])}L`
|
||||
let outerPathData2 = `M ${precise(outline[0])}L`
|
||||
|
||||
const offset = strokeWidth / 3
|
||||
|
@ -99,8 +98,8 @@ export function getDrawLinePathData(id: string, outline: VecLike[], strokeWidth:
|
|||
const len = outline.length
|
||||
|
||||
for (let i = 0, n = len - 1; i < n; i++) {
|
||||
p1 = Vec2d.AddXY(outline[i + 1], random() * offset, random() * offset)
|
||||
s1 = Vec2d.AddXY(outline[i + 1], random(), random() * offset)
|
||||
p1 = outline[i + 1]
|
||||
s1 = Vec2d.AddXY(outline[i + 1], random() * offset, random() * offset)
|
||||
|
||||
const delta = Vec2d.Sub(p1, p0)
|
||||
const distance = Vec2d.Len(delta)
|
||||
|
@ -118,11 +117,9 @@ export function getDrawLinePathData(id: string, outline: VecLike[], strokeWidth:
|
|||
|
||||
if (i === n - 1) {
|
||||
innerPathData += `${precise(q0)}L ${precise(p1)}`
|
||||
outerPathData1 += `${precise(q0)}L ${precise(p1)}`
|
||||
outerPathData2 += `${precise(sq0)}L ${precise(s1)}`
|
||||
} else {
|
||||
innerPathData += `${precise(q0)}L ${precise(q1)}Q ${precise(p1)}`
|
||||
outerPathData1 += `${precise(q0)}L ${precise(q1)}Q ${precise(p1)}`
|
||||
outerPathData2 += `${precise(sq0)}L ${precise(sq1)}Q ${precise(s1)}`
|
||||
|
||||
p0 = p1
|
||||
|
@ -130,5 +127,5 @@ export function getDrawLinePathData(id: string, outline: VecLike[], strokeWidth:
|
|||
}
|
||||
}
|
||||
|
||||
return [innerPathData, outerPathData1 + outerPathData2]
|
||||
return [innerPathData, innerPathData + outerPathData2]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue