adjust arrowhead scaling

This commit is contained in:
Gavin Nishizawa 2023-03-28 19:54:22 -07:00
parent b9fd6231e3
commit 1145c09d0f
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD

View file

@ -110,34 +110,46 @@ func arrowheadMarkerID(isTarget bool, connection d2target.Connection) string {
} }
func arrowheadDimensions(arrowhead d2target.Arrowhead, strokeWidth float64) (width, height float64) { func arrowheadDimensions(arrowhead d2target.Arrowhead, strokeWidth float64) (width, height float64) {
var widthMultiplier float64 var baseWidth, baseHeight float64
var heightMultiplier float64 var widthMultiplier, heightMultiplier float64
switch arrowhead { switch arrowhead {
case d2target.ArrowArrowhead: case d2target.ArrowArrowhead:
widthMultiplier = 5 baseWidth = 4
heightMultiplier = 5 baseHeight = 4
widthMultiplier = 4
heightMultiplier = 4
case d2target.TriangleArrowhead: case d2target.TriangleArrowhead:
widthMultiplier = 5 baseWidth = 4
heightMultiplier = 6 baseHeight = 4
widthMultiplier = 3
heightMultiplier = 4
case d2target.LineArrowhead: case d2target.LineArrowhead:
widthMultiplier = 5 widthMultiplier = 5
heightMultiplier = 8 heightMultiplier = 8
case d2target.FilledDiamondArrowhead: case d2target.FilledDiamondArrowhead:
widthMultiplier = 11 baseWidth = 11
heightMultiplier = 7 baseHeight = 7
widthMultiplier = 5.5
heightMultiplier = 3.5
case d2target.DiamondArrowhead: case d2target.DiamondArrowhead:
widthMultiplier = 11 baseWidth = 11
heightMultiplier = 9 baseHeight = 9
widthMultiplier = 5.5
heightMultiplier = 4.5
case d2target.FilledCircleArrowhead, d2target.CircleArrowhead: case d2target.FilledCircleArrowhead, d2target.CircleArrowhead:
widthMultiplier = 12 baseWidth = 8
heightMultiplier = 12 baseHeight = 8
widthMultiplier = 5
heightMultiplier = 5
case d2target.CfOne, d2target.CfMany, d2target.CfOneRequired, d2target.CfManyRequired: case d2target.CfOne, d2target.CfMany, d2target.CfOneRequired, d2target.CfManyRequired:
widthMultiplier = 9 baseWidth = 9
heightMultiplier = 9 baseHeight = 9
widthMultiplier = 4.5
heightMultiplier = 4.5
} }
clippedStrokeWidth := go2.Max(MIN_ARROWHEAD_STROKE_WIDTH, strokeWidth) clippedStrokeWidth := go2.Max(MIN_ARROWHEAD_STROKE_WIDTH, strokeWidth)
return clippedStrokeWidth * widthMultiplier, clippedStrokeWidth * heightMultiplier return baseWidth + clippedStrokeWidth*widthMultiplier, baseHeight + clippedStrokeWidth*heightMultiplier
} }
func arrowheadMarker(isTarget bool, id string, connection d2target.Connection) string { func arrowheadMarker(isTarget bool, id string, connection d2target.Connection) string {