Skip to content

Commit

Permalink
fix: default border-radius for BaseConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
ShupingHe committed Mar 1, 2023
1 parent 776b6af commit e88c60f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 0 additions & 2 deletions d2exporter/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ func toConnection(edge *d2graph.Edge) d2target.Connection {

if edge.Attributes.Style.BorderRadius != nil {
connection.BorderRadius, _ = strconv.ParseFloat(edge.Attributes.Style.BorderRadius.Value, 64)
} else {
connection.BorderRadius = -1
}

if edge.Attributes.Style.Opacity != nil {
Expand Down
3 changes: 0 additions & 3 deletions d2renderers/d2svg/d2svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,6 @@ func pathData(connection d2target.Connection, srcAdj, dstAdj *geo.Point) string
dist := geo.EuclideanDistance(prevTarget.X, prevTarget.Y, currTarget.X, currTarget.Y)

connectionBorderRadius := connection.BorderRadius
if connectionBorderRadius < 0 {
connectionBorderRadius = 10
}
units := math.Min(connectionBorderRadius, dist/2)

prevTranslations := prevVector.Unit().Multiply(units).ToPoint()
Expand Down
13 changes: 7 additions & 6 deletions d2target/d2target.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,13 @@ type Connection struct {

func BaseConnection() *Connection {
return &Connection{
SrcArrow: NoArrowhead,
DstArrow: NoArrowhead,
Route: make([]*geo.Point, 0),
Opacity: 1,
StrokeDash: 0,
StrokeWidth: 2,
SrcArrow: NoArrowhead,
DstArrow: NoArrowhead,
Route: make([]*geo.Point, 0),
Opacity: 1,
StrokeDash: 0,
StrokeWidth: 2,
BorderRadius: 10,
Text: Text{
Italic: true,
FontFamily: "DEFAULT",
Expand Down

0 comments on commit e88c60f

Please sign in to comment.