lint try
Signed-off-by: Mayank Mohapatra <125661248+Mayank77maruti@users.noreply.github.com>
This commit is contained in:
parent
5b28501fd9
commit
090a225ec0
4 changed files with 9 additions and 10 deletions
|
|
@ -4,4 +4,4 @@ import "oss.terrastruct.com/d2/d2target"
|
||||||
|
|
||||||
func (obj *Object) IsCycleDiagram() bool {
|
func (obj *Object) IsCycleDiagram() bool {
|
||||||
return obj != nil && obj.Shape.Value == d2target.ShapeCycleDiagram
|
return obj != nil && obj.Shape.Value == d2target.ShapeCycleDiagram
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ func positionObjects(objects []*d2graph.Object, radius float64) {
|
||||||
angleOffset := -math.Pi / 2
|
angleOffset := -math.Pi / 2
|
||||||
|
|
||||||
for i, obj := range objects {
|
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)
|
x := radius * math.Cos(angle)
|
||||||
y := radius * math.Sin(angle)
|
y := radius * math.Sin(angle)
|
||||||
obj.TopLeft = geo.NewPoint(
|
obj.TopLeft = geo.NewPoint(
|
||||||
|
|
@ -117,7 +117,7 @@ func createCircularArc(edge *d2graph.Edge) {
|
||||||
tangentX /= mag
|
tangentX /= mag
|
||||||
tangentY /= mag
|
tangentY /= mag
|
||||||
}
|
}
|
||||||
const MIN_SEGMENT_LEN = 4.159
|
const MIN_SEGMENT_LEN = 4.159
|
||||||
|
|
||||||
dx := lastPoint.X - secondLastPoint.X
|
dx := lastPoint.X - secondLastPoint.X
|
||||||
dy := lastPoint.Y - secondLastPoint.Y
|
dy := lastPoint.Y - secondLastPoint.Y
|
||||||
|
|
@ -129,9 +129,9 @@ func createCircularArc(edge *d2graph.Edge) {
|
||||||
// Check if we need to adjust the direction
|
// Check if we need to adjust the direction
|
||||||
if segLength < MIN_SEGMENT_LEN || (currentDirX*tangentX+currentDirY*tangentY) < 0.999 {
|
if segLength < MIN_SEGMENT_LEN || (currentDirX*tangentX+currentDirY*tangentY) < 0.999 {
|
||||||
// Create new point along tangent direction
|
// Create new point along tangent direction
|
||||||
adjustLength := MIN_SEGMENT_LEN // Now float64
|
adjustLength := MIN_SEGMENT_LEN // Now float64
|
||||||
if segLength >= MIN_SEGMENT_LEN {
|
if segLength >= MIN_SEGMENT_LEN {
|
||||||
adjustLength = segLength // Both are float64 now
|
adjustLength = segLength // Both are float64 now
|
||||||
}
|
}
|
||||||
newSecondLastX := lastPoint.X - tangentX*adjustLength
|
newSecondLastX := lastPoint.X - tangentX*adjustLength
|
||||||
newSecondLastY := lastPoint.Y - tangentY*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,
|
// clampPointOutsideBox walks forward along the path until it finds a point outside the box,
|
||||||
// then replaces the point with a precise intersection.
|
// then replaces the point with a precise intersection.
|
||||||
func clampPointOutsideBox(box *geo.Box, path []*geo.Point, startIdx int) (int, *geo.Point) {
|
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 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.
|
// clampPointOutsideBoxReverse works similarly but in reverse order.
|
||||||
|
|
@ -326,4 +325,4 @@ func positionLabelsIcons(obj *d2graph.Object) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ func LayoutNested(ctx context.Context, g *d2graph.Graph, graphInfo GraphInfo, co
|
||||||
err = d2cycle.Layout(ctx, g, coreLayout)
|
err = d2cycle.Layout(ctx, g, coreLayout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
log.Debug(ctx, "default layout", slog.Any("rootlevel", g.RootLevel), slog.Any("shapes", g.PrintString()))
|
log.Debug(ctx, "default layout", slog.Any("rootlevel", g.RootLevel), slog.Any("shapes", g.PrintString()))
|
||||||
err := coreLayout(ctx, g)
|
err := coreLayout(ctx, g)
|
||||||
|
|
|
||||||
|
|
@ -331,4 +331,4 @@ func (v Vector) Normalize() Vector {
|
||||||
return Vector{0, 0}
|
return Vector{0, 0}
|
||||||
}
|
}
|
||||||
return Vector{v[0] / length, v[1] / length}
|
return Vector{v[0] / length, v[1] / length}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue