update tracing to label box
This commit is contained in:
parent
5d7b0af127
commit
b1cb08027e
2 changed files with 16 additions and 0 deletions
|
|
@ -336,6 +336,12 @@ func (edge *Edge) TraceToShape(points []*geo.Point, startIndex, endIndex int) (n
|
|||
// add left/right padding to box
|
||||
labelBox.TopLeft.X -= label.PADDING
|
||||
labelBox.Width += 2 * label.PADDING
|
||||
|
||||
for labelBox.Contains(startingSegment.End) && startIndex+1 > endIndex {
|
||||
startingSegment.Start = startingSegment.End
|
||||
startingSegment.End = points[startIndex+2]
|
||||
startIndex++
|
||||
}
|
||||
if intersections := labelBox.Intersections(startingSegment); len(intersections) > 0 {
|
||||
overlapsOutsideLabel = true
|
||||
p := intersections[0]
|
||||
|
|
@ -381,6 +387,11 @@ func (edge *Edge) TraceToShape(points []*geo.Point, startIndex, endIndex int) (n
|
|||
// add left/right padding to box
|
||||
labelBox.TopLeft.X -= label.PADDING
|
||||
labelBox.Width += 2 * label.PADDING
|
||||
for labelBox.Contains(endingSegment.Start) && endIndex-1 > startIndex {
|
||||
endingSegment.End = endingSegment.Start
|
||||
endingSegment.Start = points[endIndex-2]
|
||||
endIndex--
|
||||
}
|
||||
if intersections := labelBox.Intersections(endingSegment); len(intersections) > 0 {
|
||||
overlapsOutsideLabel = true
|
||||
p := intersections[0]
|
||||
|
|
|
|||
|
|
@ -78,3 +78,8 @@ func (b *Box) ToString() string {
|
|||
}
|
||||
return fmt.Sprintf("{TopLeft: %s, Width: %.0f, Height: %.0f}", b.TopLeft.ToString(), b.Width, b.Height)
|
||||
}
|
||||
|
||||
func (b *Box) Contains(p *Point) bool {
|
||||
return !(p.X < b.TopLeft.X || b.TopLeft.X+b.Width < p.X ||
|
||||
p.Y < b.TopLeft.Y || b.TopLeft.Y+b.Height < p.Y)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue