diff --git a/d2exporter/export.go b/d2exporter/export.go index 1331becaa..bc84f4246 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -206,6 +206,10 @@ func toConnection(edge *d2graph.Edge) d2target.Connection { } } + if edge.Attributes.Style.BorderRadius != nil { + connection.BorderRadius, _ = strconv.ParseFloat(edge.Attributes.Style.BorderRadius.Value, 64) + } + if edge.Attributes.Style.Opacity != nil { connection.Opacity, _ = strconv.ParseFloat(edge.Attributes.Style.Opacity.Value, 64) } diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index f4d821e0b..18484c05f 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -419,7 +419,12 @@ func pathData(connection d2target.Connection, srcAdj, dstAdj *geo.Point) string currVector := prevTarget.VectorTo(currTarget) dist := geo.EuclideanDistance(prevTarget.X, prevTarget.Y, currTarget.X, currTarget.Y) - units := math.Min(10, dist/2) + + connectionBorderRadius := connection.BorderRadius + if connectionBorderRadius == 0 { + connectionBorderRadius = 10 + } + units := math.Min(connectionBorderRadius, dist/2) prevTranslations := prevVector.Unit().Multiply(units).ToPoint() currTranslations := currVector.Unit().Multiply(units).ToPoint() @@ -430,7 +435,7 @@ func pathData(connection d2target.Connection, srcAdj, dstAdj *geo.Point) string )) // If the segment length is too small, instead of drawing 2 arcs, just skip this segment and bezier curve to the next one - if units < 10 && i < len(route)-2 { + if units < connectionBorderRadius && i < len(route)-2 { nextTarget := route[i+2] nextVector := geo.NewVector(nextTarget.X-currTarget.X, nextTarget.Y-currTarget.Y) i++ diff --git a/d2target/d2target.go b/d2target/d2target.go index c6da41188..5d2fa6f95 100644 --- a/d2target/d2target.go +++ b/d2target/d2target.go @@ -293,11 +293,12 @@ type Connection struct { DstArrow Arrowhead `json:"dstArrow"` DstLabel string `json:"dstLabel"` - Opacity float64 `json:"opacity"` - StrokeDash float64 `json:"strokeDash"` - StrokeWidth int `json:"strokeWidth"` - Stroke string `json:"stroke"` - Fill string `json:"fill,omitempty"` + Opacity float64 `json:"opacity"` + StrokeDash float64 `json:"strokeDash"` + StrokeWidth int `json:"strokeWidth"` + Stroke string `json:"stroke"` + Fill string `json:"fill,omitempty"` + BorderRadius float64 `json:"borderRadius,omitempty"` Text LabelPosition string `json:"labelPosition"`