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 {
|
if edge.Attributes.Style.Opacity != nil {
|
||||||
connection.Opacity, _ = strconv.ParseFloat(edge.Attributes.Style.Opacity.Value, 64)
|
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)
|
currVector := prevTarget.VectorTo(currTarget)
|
||||||
|
|
||||||
dist := geo.EuclideanDistance(prevTarget.X, prevTarget.Y, currTarget.X, currTarget.Y)
|
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()
|
prevTranslations := prevVector.Unit().Multiply(units).ToPoint()
|
||||||
currTranslations := currVector.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 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]
|
nextTarget := route[i+2]
|
||||||
nextVector := geo.NewVector(nextTarget.X-currTarget.X, nextTarget.Y-currTarget.Y)
|
nextVector := geo.NewVector(nextTarget.X-currTarget.X, nextTarget.Y-currTarget.Y)
|
||||||
i++
|
i++
|
||||||
|
|
|
||||||
|
|
@ -293,11 +293,12 @@ type Connection struct {
|
||||||
DstArrow Arrowhead `json:"dstArrow"`
|
DstArrow Arrowhead `json:"dstArrow"`
|
||||||
DstLabel string `json:"dstLabel"`
|
DstLabel string `json:"dstLabel"`
|
||||||
|
|
||||||
Opacity float64 `json:"opacity"`
|
Opacity float64 `json:"opacity"`
|
||||||
StrokeDash float64 `json:"strokeDash"`
|
StrokeDash float64 `json:"strokeDash"`
|
||||||
StrokeWidth int `json:"strokeWidth"`
|
StrokeWidth int `json:"strokeWidth"`
|
||||||
Stroke string `json:"stroke"`
|
Stroke string `json:"stroke"`
|
||||||
Fill string `json:"fill,omitempty"`
|
Fill string `json:"fill,omitempty"`
|
||||||
|
BorderRadius float64 `json:"borderRadius,omitempty"`
|
||||||
|
|
||||||
Text
|
Text
|
||||||
LabelPosition string `json:"labelPosition"`
|
LabelPosition string `json:"labelPosition"`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue