diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index ec3347d55..2f7f931f0 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -225,18 +225,16 @@ func arrowheadMarker(isTarget bool, id string, connection d2target.Connection) s } case d2target.CfOne, d2target.CfMany, d2target.CfOneRequired, d2target.CfManyRequired: attrs := fmt.Sprintf(`class="connection" stroke="%s" stroke-width="%d" fill="white"`, connection.Stroke, connection.StrokeWidth) - offset := 4.0 + (float64(connection.StrokeWidth) * 2.0) + offset := 4.0 + float64(connection.StrokeWidth*2) var modifier string if arrowhead == d2target.CfOneRequired || arrowhead == d2target.CfManyRequired { - modifier = fmt.Sprintf(``, + modifier = fmt.Sprintf(``, attrs, - width, height/2.0, - offset/2.0+1.0, height/2.0, offset, 0., offset, height, ) } else { - modifier = fmt.Sprintf(``, + modifier = fmt.Sprintf(``, attrs, offset/2.0+1.0, height/2.0, offset/2.0, @@ -246,9 +244,9 @@ func arrowheadMarker(isTarget bool, id string, connection d2target.Connection) s attrs = fmt.Sprintf(`%s transform="scale(-1) translate(-%f, -%f)"`, attrs, width, height) } if arrowhead == d2target.CfMany || arrowhead == d2target.CfManyRequired { - path = fmt.Sprintf(`%s`, + path = fmt.Sprintf(`%s`, attrs, modifier, - offset+2.0, height/2.0, + width-3.0, height/2.0, width+offset, height/2.0, offset+2.0, height/2.0, width+offset, 0., @@ -256,9 +254,9 @@ func arrowheadMarker(isTarget bool, id string, connection d2target.Connection) s width+offset, height, ) } else { - path = fmt.Sprintf(`%s`, + path = fmt.Sprintf(`%s`, attrs, modifier, - offset+2.0, height/2.0, + width-3.0, height/2.0, width+offset, height/2.0, offset*1.8, 0., offset*1.8, height, diff --git a/e2etests/stable_test.go b/e2etests/stable_test.go index 3e442c4a4..a8acc138a 100644 --- a/e2etests/stable_test.go +++ b/e2etests/stable_test.go @@ -1728,6 +1728,8 @@ package.height: 512 name: "crow_foot_arrowhead", script: ` a <-> b: { + style.stroke-width: 3 + style.stroke: "#20222a" source-arrowhead: { shape: cf-many } @@ -1735,7 +1737,9 @@ a <-> b: { shape: cf-many } } -c <--> d: { +c <--> d <-> f: { + style.stroke-width: 1 + style.stroke: "orange" source-arrowhead: { shape: cf-many-required } diff --git a/e2etests/testdata/stable/crow_foot_arrowhead/dagre/board.exp.json b/e2etests/testdata/stable/crow_foot_arrowhead/dagre/board.exp.json index afdf45d69..0784c5506 100644 --- a/e2etests/testdata/stable/crow_foot_arrowhead/dagre/board.exp.json +++ b/e2etests/testdata/stable/crow_foot_arrowhead/dagre/board.exp.json @@ -162,6 +162,46 @@ "zIndex": 0, "level": 1 }, + { + "id": "f", + "type": "", + "pos": { + "x": 348, + "y": 452 + }, + "width": 111, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "f", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 11, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, { "id": "g", "type": "", @@ -246,8 +286,8 @@ "id": "e", "type": "", "pos": { - "x": 521, - "y": 0 + "x": 520, + "y": 226 }, "width": 113, "height": 126, @@ -281,46 +321,6 @@ "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, "level": 1 - }, - { - "id": "f", - "type": "", - "pos": { - "x": 522, - "y": 226 - }, - "width": 111, - "height": 126, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#F7F8FE", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": false, - "fields": null, - "methods": null, - "columns": null, - "label": "f", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": true, - "underline": false, - "labelWidth": 11, - "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 1 } ], "connections": [ @@ -334,8 +334,8 @@ "dstLabel": "", "opacity": 1, "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", + "strokeWidth": 3, + "stroke": "#20222a", "label": "", "fontSize": 16, "fontFamily": "DEFAULT", @@ -382,8 +382,8 @@ "dstLabel": "", "opacity": 1, "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", + "strokeWidth": 1, + "stroke": "orange", "label": "", "fontSize": 16, "fontFamily": "DEFAULT", @@ -420,6 +420,54 @@ "icon": null, "zIndex": 0 }, + { + "id": "(d <-> f)[0]", + "src": "d", + "srcArrow": "cf-many-required", + "srcLabel": "", + "dst": "f", + "dstArrow": "cf-many-required", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 1, + "stroke": "orange", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 230, + "y": 352 + }, + { + "x": 230, + "y": 392 + }, + { + "x": 253.55, + "y": 417.36017316017313 + }, + { + "x": 347.75, + "y": 478.8008658008658 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, { "id": "(g <-> h)[0]", "src": "g", @@ -494,20 +542,20 @@ "labelPercentage": 0, "route": [ { - "x": 577, - "y": 126 + "x": 576.5, + "y": 352 }, { - "x": 577, - "y": 166 + "x": 576.5, + "y": 392 }, { - "x": 577, - "y": 186 + "x": 552.9, + "y": 417.4 }, { - "x": 577, - "y": 226 + "x": 458.5, + "y": 479 } ], "isCurve": true, diff --git a/e2etests/testdata/stable/crow_foot_arrowhead/dagre/sketch.exp.svg b/e2etests/testdata/stable/crow_foot_arrowhead/dagre/sketch.exp.svg index 221316bd3..cc439add7 100644 --- a/e2etests/testdata/stable/crow_foot_arrowhead/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/crow_foot_arrowhead/dagre/sketch.exp.svg @@ -2,7 +2,7 @@ abcdfghe + abcdghef - +abcdfghe +