feat: elk border-radius
This commit is contained in:
parent
2ddea9352e
commit
84905ded9e
3 changed files with 17 additions and 7 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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++
|
||||
|
|
|
|||
|
|
@ -298,6 +298,7 @@ type Connection struct {
|
|||
StrokeWidth int `json:"strokeWidth"`
|
||||
Stroke string `json:"stroke"`
|
||||
Fill string `json:"fill,omitempty"`
|
||||
BorderRadius float64 `json:"borderRadius,omitempty"`
|
||||
|
||||
Text
|
||||
LabelPosition string `json:"labelPosition"`
|
||||
|
|
|
|||
Loading…
Reference in a new issue