diff --git a/d2graph/cyclediagram.go b/d2graph/cyclediagram.go index 1014dd1e8..a8f8e0b1a 100644 --- a/d2graph/cyclediagram.go +++ b/d2graph/cyclediagram.go @@ -4,4 +4,4 @@ import "oss.terrastruct.com/d2/d2target" func (obj *Object) IsCycleDiagram() bool { return obj != nil && obj.Shape.Value == d2target.ShapeCycleDiagram -} \ No newline at end of file +} diff --git a/d2layouts/d2cycle/layout.go b/d2layouts/d2cycle/layout.go index 8ef08e7c8..73f663551 100644 --- a/d2layouts/d2cycle/layout.go +++ b/d2layouts/d2cycle/layout.go @@ -55,7 +55,7 @@ func positionObjects(objects []*d2graph.Object, radius float64) { angleOffset := -math.Pi / 2 for i, obj := range objects { - angle := angleOffset + (2*math.Pi*float64(i)/numObjects) + angle := angleOffset + (2 * math.Pi * float64(i) / numObjects) x := radius * math.Cos(angle) y := radius * math.Sin(angle) obj.TopLeft = geo.NewPoint( @@ -117,7 +117,7 @@ func createCircularArc(edge *d2graph.Edge) { tangentX /= mag tangentY /= mag } - const MIN_SEGMENT_LEN = 4.159 + const MIN_SEGMENT_LEN = 4.159 dx := lastPoint.X - secondLastPoint.X dy := lastPoint.Y - secondLastPoint.Y @@ -129,9 +129,9 @@ func createCircularArc(edge *d2graph.Edge) { // Check if we need to adjust the direction if segLength < MIN_SEGMENT_LEN || (currentDirX*tangentX+currentDirY*tangentY) < 0.999 { // Create new point along tangent direction - adjustLength := MIN_SEGMENT_LEN // Now float64 + adjustLength := MIN_SEGMENT_LEN // Now float64 if segLength >= MIN_SEGMENT_LEN { - adjustLength = segLength // Both are float64 now + adjustLength = segLength // Both are float64 now } newSecondLastX := lastPoint.X - tangentX*adjustLength newSecondLastY := lastPoint.Y - tangentY*adjustLength @@ -141,7 +141,6 @@ func createCircularArc(edge *d2graph.Edge) { } } - // clampPointOutsideBox walks forward along the path until it finds a point outside the box, // then replaces the point with a precise intersection. func clampPointOutsideBox(box *geo.Box, path []*geo.Point, startIdx int) (int, *geo.Point) { @@ -163,7 +162,7 @@ func clampPointOutsideBox(box *geo.Box, path []*geo.Point, startIdx int) (int, * } return i, path[i] } - return len(path)-1, path[len(path)-1] + return len(path) - 1, path[len(path)-1] } // clampPointOutsideBoxReverse works similarly but in reverse order. @@ -326,4 +325,4 @@ func positionLabelsIcons(obj *d2graph.Object) { } } } -} \ No newline at end of file +} diff --git a/d2layouts/d2layouts.go b/d2layouts/d2layouts.go index d4dc1ad81..7e813953a 100644 --- a/d2layouts/d2layouts.go +++ b/d2layouts/d2layouts.go @@ -267,7 +267,7 @@ func LayoutNested(ctx context.Context, g *d2graph.Graph, graphInfo GraphInfo, co err = d2cycle.Layout(ctx, g, coreLayout) if err != nil { return err - } + } default: log.Debug(ctx, "default layout", slog.Any("rootlevel", g.RootLevel), slog.Any("shapes", g.PrintString())) err := coreLayout(ctx, g) diff --git a/lib/geo/point.go b/lib/geo/point.go index 47882bb18..8883010cc 100644 --- a/lib/geo/point.go +++ b/lib/geo/point.go @@ -331,4 +331,4 @@ func (v Vector) Normalize() Vector { return Vector{0, 0} } return Vector{v[0] / length, v[1] / length} -} \ No newline at end of file +}