fix dagre_broken_arrowhead
This commit is contained in:
parent
e52f0bb8ba
commit
a32319d598
2 changed files with 6 additions and 6 deletions
|
|
@ -346,7 +346,7 @@ func (edge *Edge) TraceToShape(points []*geo.Point, startIndex, endIndex int) (n
|
|||
points[startIndex] = p
|
||||
startingSegment.End = p
|
||||
// if the segment becomes too short, just merge it with the next segment
|
||||
if startIndex+1 < len(points)-1 && startingSegment.Length() < MIN_SEGMENT_LEN {
|
||||
if startIndex+1 < endIndex && startingSegment.Length() < MIN_SEGMENT_LEN {
|
||||
points[startIndex+1] = points[startIndex]
|
||||
startIndex++
|
||||
}
|
||||
|
|
@ -359,7 +359,7 @@ func (edge *Edge) TraceToShape(points []*geo.Point, startIndex, endIndex int) (n
|
|||
points[startIndex] = intersections[0]
|
||||
startingSegment.End = intersections[0]
|
||||
// if the segment becomes too short, just merge it with the next segment
|
||||
if startIndex+1 < len(points)-1 && startingSegment.Length() < MIN_SEGMENT_LEN {
|
||||
if startIndex+1 < endIndex && startingSegment.Length() < MIN_SEGMENT_LEN {
|
||||
points[startIndex+1] = points[startIndex]
|
||||
startIndex++
|
||||
}
|
||||
|
|
@ -391,7 +391,7 @@ func (edge *Edge) TraceToShape(points []*geo.Point, startIndex, endIndex int) (n
|
|||
points[endIndex] = p
|
||||
endingSegment.End = p
|
||||
// if the segment becomes too short, just merge it with the previous segment
|
||||
if endIndex-1 > 0 && endingSegment.Length() < MIN_SEGMENT_LEN {
|
||||
if endIndex-1 > startIndex && endingSegment.Length() < MIN_SEGMENT_LEN {
|
||||
points[endIndex-1] = points[endIndex]
|
||||
endIndex--
|
||||
}
|
||||
|
|
@ -404,7 +404,7 @@ func (edge *Edge) TraceToShape(points []*geo.Point, startIndex, endIndex int) (n
|
|||
points[endIndex] = intersections[0]
|
||||
endingSegment.End = intersections[0]
|
||||
// if the segment becomes too short, just merge it with the previous segment
|
||||
if endIndex-1 > 0 && endingSegment.Length() < MIN_SEGMENT_LEN {
|
||||
if endIndex-1 > startIndex && endingSegment.Length() < MIN_SEGMENT_LEN {
|
||||
points[endIndex-1] = points[endIndex]
|
||||
endIndex--
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
|||
|
||||
// arrowheads can appear broken if segments are very short from dagre routing a point just outside the shape
|
||||
// to fix this, we try extending the previous segment into the shape instead of having a very short segment
|
||||
if !start.Equals(points[0]) && startIndex+2 < len(points) {
|
||||
if startIndex+2 < len(points) {
|
||||
newStartingSegment := *geo.NewSegment(start, points[startIndex+1])
|
||||
if newStartingSegment.Length() < d2graph.MIN_SEGMENT_LEN {
|
||||
// we don't want a very short segment right next to the source because it will mess up the arrowhead
|
||||
|
|
@ -294,7 +294,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
|
|||
}
|
||||
}
|
||||
}
|
||||
if !end.Equals(points[len(points)-1]) && endIndex-2 >= 0 {
|
||||
if endIndex-2 >= 0 {
|
||||
newEndingSegment := *geo.NewSegment(end, points[endIndex-1])
|
||||
if newEndingSegment.Length() < d2graph.MIN_SEGMENT_LEN {
|
||||
// extend the prev segment into the shape border if possible
|
||||
|
|
|
|||
Loading…
Reference in a new issue