Init
This commit is contained in:
parent
cfed25be63
commit
b0d3b9d3fd
4 changed files with 80 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
#### Features 🚀
|
#### Features 🚀
|
||||||
|
- Circle notation is now supported. []
|
||||||
#### Improvements 🧹
|
#### Improvements 🧹
|
||||||
|
|
||||||
#### Bugfixes ⛑️
|
#### Bugfixes ⛑️
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,12 @@ func arrowheadDimensions(arrowhead d2target.Arrowhead, strokeWidth float64) (wid
|
||||||
case d2target.DiamondArrowhead:
|
case d2target.DiamondArrowhead:
|
||||||
widthMultiplier = 11
|
widthMultiplier = 11
|
||||||
heightMultiplier = 9
|
heightMultiplier = 9
|
||||||
|
case d2target.FilledCircleArrowhead:
|
||||||
|
widthMultiplier = 14
|
||||||
|
heightMultiplier = 15
|
||||||
|
case d2target.CircleArrowhead:
|
||||||
|
widthMultiplier = 14
|
||||||
|
heightMultiplier = 15
|
||||||
case d2target.CfOne, d2target.CfMany, d2target.CfOneRequired, d2target.CfManyRequired:
|
case d2target.CfOne, d2target.CfMany, d2target.CfOneRequired, d2target.CfManyRequired:
|
||||||
widthMultiplier = 14
|
widthMultiplier = 14
|
||||||
heightMultiplier = 15
|
heightMultiplier = 15
|
||||||
|
|
@ -224,6 +230,39 @@ func arrowheadMarker(isTarget bool, id string, connection d2target.Connection) s
|
||||||
width*0.6, height*7/8,
|
width*0.6, height*7/8,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
case d2target.FilledCircleArrowhead:
|
||||||
|
attrs := fmt.Sprintf(`class="connection" fill="%s" stroke-width="%d"`, connection.Stroke, connection.StrokeWidth)
|
||||||
|
offset := 4.0 + float64(connection.StrokeWidth*2)
|
||||||
|
if isTarget {
|
||||||
|
path = fmt.Sprintf(`<circle %s cx="%f" cy="%f" r="%f"/>`,
|
||||||
|
attrs,
|
||||||
|
offset+9, height/2,
|
||||||
|
offset*1.2,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
path = fmt.Sprintf(`<circle %s cx="%f" cy="%f" r="%f"/>`,
|
||||||
|
attrs,
|
||||||
|
offset+3, height/2,
|
||||||
|
offset*1.2,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case d2target.CircleArrowhead:
|
||||||
|
attrs := fmt.Sprintf(`class="connection" fill="white" stroke="%s" stroke-width="%d"`, connection.Stroke, connection.StrokeWidth)
|
||||||
|
offset := 4.0 + float64(connection.StrokeWidth*2)
|
||||||
|
if isTarget {
|
||||||
|
path = fmt.Sprintf(`<circle %s cx="%f" cy="%f" r="%f"/>`,
|
||||||
|
attrs,
|
||||||
|
offset+10, height/2,
|
||||||
|
offset*1.2,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
path = fmt.Sprintf(`<circle %s cx="%f" cy="%f" r="%f"/>`,
|
||||||
|
attrs,
|
||||||
|
offset+6, height/2,
|
||||||
|
offset*1.2,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
case d2target.CfOne, d2target.CfMany, d2target.CfOneRequired, d2target.CfManyRequired:
|
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)
|
attrs := fmt.Sprintf(`class="connection" stroke="%s" stroke-width="%d" fill="white"`, connection.Stroke, connection.StrokeWidth)
|
||||||
offset := 4.0 + float64(connection.StrokeWidth*2)
|
offset := 4.0 + float64(connection.StrokeWidth*2)
|
||||||
|
|
@ -277,6 +316,14 @@ func arrowheadMarker(isTarget bool, id string, connection d2target.Connection) s
|
||||||
refX = width/8 + 0.6*strokeWidth
|
refX = width/8 + 0.6*strokeWidth
|
||||||
}
|
}
|
||||||
width *= 1.1
|
width *= 1.1
|
||||||
|
|
||||||
|
case d2target.CircleArrowhead:
|
||||||
|
if isTarget {
|
||||||
|
refX = width - 0.6*strokeWidth
|
||||||
|
} else {
|
||||||
|
refX = width/8 + 0.6*strokeWidth
|
||||||
|
}
|
||||||
|
width *= 1.1
|
||||||
default:
|
default:
|
||||||
if isTarget {
|
if isTarget {
|
||||||
refX = width - 1.5*strokeWidth
|
refX = width - 1.5*strokeWidth
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,8 @@ const (
|
||||||
TriangleArrowhead Arrowhead = "triangle"
|
TriangleArrowhead Arrowhead = "triangle"
|
||||||
DiamondArrowhead Arrowhead = "diamond"
|
DiamondArrowhead Arrowhead = "diamond"
|
||||||
FilledDiamondArrowhead Arrowhead = "filled-diamond"
|
FilledDiamondArrowhead Arrowhead = "filled-diamond"
|
||||||
|
CircleArrowhead Arrowhead = "circle"
|
||||||
|
FilledCircleArrowhead Arrowhead = "circle-filled"
|
||||||
|
|
||||||
// For fat arrows
|
// For fat arrows
|
||||||
LineArrowhead Arrowhead = "line"
|
LineArrowhead Arrowhead = "line"
|
||||||
|
|
@ -294,6 +296,8 @@ var Arrowheads = map[string]struct{}{
|
||||||
string(TriangleArrowhead): {},
|
string(TriangleArrowhead): {},
|
||||||
string(DiamondArrowhead): {},
|
string(DiamondArrowhead): {},
|
||||||
string(FilledDiamondArrowhead): {},
|
string(FilledDiamondArrowhead): {},
|
||||||
|
string(CircleArrowhead): {},
|
||||||
|
string(FilledCircleArrowhead): {},
|
||||||
string(CfOne): {},
|
string(CfOne): {},
|
||||||
string(CfMany): {},
|
string(CfMany): {},
|
||||||
string(CfOneRequired): {},
|
string(CfOneRequired): {},
|
||||||
|
|
@ -307,6 +311,11 @@ func ToArrowhead(arrowheadType string, filled bool) Arrowhead {
|
||||||
return FilledDiamondArrowhead
|
return FilledDiamondArrowhead
|
||||||
}
|
}
|
||||||
return DiamondArrowhead
|
return DiamondArrowhead
|
||||||
|
case string(CircleArrowhead):
|
||||||
|
if filled {
|
||||||
|
return FilledCircleArrowhead
|
||||||
|
}
|
||||||
|
return CircleArrowhead
|
||||||
case string(ArrowArrowhead):
|
case string(ArrowArrowhead):
|
||||||
return ArrowArrowhead
|
return ArrowArrowhead
|
||||||
case string(CfOne):
|
case string(CfOne):
|
||||||
|
|
|
||||||
|
|
@ -1762,6 +1762,29 @@ e <--> f: {
|
||||||
target-arrowhead: {
|
target-arrowhead: {
|
||||||
shape: cf-one-required
|
shape: cf-one-required
|
||||||
}
|
}
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "circle_arrowhead",
|
||||||
|
script: `
|
||||||
|
a <-> b: circle {
|
||||||
|
source-arrowhead: {
|
||||||
|
shape: circle
|
||||||
|
}
|
||||||
|
target-arrowhead: {
|
||||||
|
shape: circle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c <--> d: circle-filled {
|
||||||
|
source-arrowhead: {
|
||||||
|
shape: circle
|
||||||
|
style.filled: true
|
||||||
|
}
|
||||||
|
target-arrowhead: {
|
||||||
|
shape: circle
|
||||||
|
style.filled: true
|
||||||
|
}
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue