arrowheads respect background color in sketch mode
This commit is contained in:
parent
7ce8e135f9
commit
cfdf59b6b6
2 changed files with 12 additions and 9 deletions
|
|
@ -572,7 +572,7 @@ func extractPathData(roughPaths []roughPath) ([]string, error) {
|
||||||
return paths, nil
|
return paths, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ArrowheadJS(r *Runner, arrowhead d2target.Arrowhead, stroke string, strokeWidth int) (arrowJS, extraJS string) {
|
func ArrowheadJS(r *Runner, bgColor string, arrowhead d2target.Arrowhead, stroke string, strokeWidth int) (arrowJS, extraJS string) {
|
||||||
// Note: selected each seed that looks the good for consistent renders
|
// Note: selected each seed that looks the good for consistent renders
|
||||||
switch arrowhead {
|
switch arrowhead {
|
||||||
case d2target.ArrowArrowhead:
|
case d2target.ArrowArrowhead:
|
||||||
|
|
@ -592,10 +592,11 @@ func ArrowheadJS(r *Runner, arrowhead d2target.Arrowhead, stroke string, strokeW
|
||||||
)
|
)
|
||||||
case d2target.DiamondArrowhead:
|
case d2target.DiamondArrowhead:
|
||||||
arrowJS = fmt.Sprintf(
|
arrowJS = fmt.Sprintf(
|
||||||
`node = rc.polygon(%s, { strokeWidth: %d, stroke: "%s", fill: "white", fillStyle: "solid", seed: 1 })`,
|
`node = rc.polygon(%s, { strokeWidth: %d, stroke: "%s", fill: "%s", fillStyle: "solid", seed: 1 })`,
|
||||||
`[[-20, 0], [-10, 5], [0, 0], [-10, -5], [-20, 0]]`,
|
`[[-20, 0], [-10, 5], [0, 0], [-10, -5], [-20, 0]]`,
|
||||||
strokeWidth,
|
strokeWidth,
|
||||||
stroke,
|
stroke,
|
||||||
|
bgColor,
|
||||||
)
|
)
|
||||||
case d2target.FilledDiamondArrowhead:
|
case d2target.FilledDiamondArrowhead:
|
||||||
arrowJS = fmt.Sprintf(
|
arrowJS = fmt.Sprintf(
|
||||||
|
|
@ -623,9 +624,10 @@ func ArrowheadJS(r *Runner, arrowhead d2target.Arrowhead, stroke string, strokeW
|
||||||
stroke,
|
stroke,
|
||||||
)
|
)
|
||||||
extraJS = fmt.Sprintf(
|
extraJS = fmt.Sprintf(
|
||||||
`node = rc.circle(-20, 0, 8, { strokeWidth: %d, stroke: "%s", fill: "white", fillStyle: "solid", fillWeight: 1, seed: 4 })`,
|
`node = rc.circle(-20, 0, 8, { strokeWidth: %d, stroke: "%s", fill: "%s", fillStyle: "solid", fillWeight: 1, seed: 4 })`,
|
||||||
strokeWidth,
|
strokeWidth,
|
||||||
stroke,
|
stroke,
|
||||||
|
bgColor,
|
||||||
)
|
)
|
||||||
case d2target.CfOneRequired:
|
case d2target.CfOneRequired:
|
||||||
arrowJS = fmt.Sprintf(
|
arrowJS = fmt.Sprintf(
|
||||||
|
|
@ -644,19 +646,20 @@ func ArrowheadJS(r *Runner, arrowhead d2target.Arrowhead, stroke string, strokeW
|
||||||
stroke,
|
stroke,
|
||||||
)
|
)
|
||||||
extraJS = fmt.Sprintf(
|
extraJS = fmt.Sprintf(
|
||||||
`node = rc.circle(-20, 0, 8, { strokeWidth: %d, stroke: "%s", fill: "white", fillStyle: "solid", fillWeight: 1, seed: 5 })`,
|
`node = rc.circle(-20, 0, 8, { strokeWidth: %d, stroke: "%s", fill: "%s", fillStyle: "solid", fillWeight: 1, seed: 5 })`,
|
||||||
strokeWidth,
|
strokeWidth,
|
||||||
stroke,
|
stroke,
|
||||||
|
bgColor,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func Arrowheads(r *Runner, connection d2target.Connection, srcAdj, dstAdj *geo.Point) (string, error) {
|
func Arrowheads(r *Runner, bgColor string, connection d2target.Connection, srcAdj, dstAdj *geo.Point) (string, error) {
|
||||||
arrowPaths := []string{}
|
arrowPaths := []string{}
|
||||||
|
|
||||||
if connection.SrcArrow != d2target.NoArrowhead {
|
if connection.SrcArrow != d2target.NoArrowhead {
|
||||||
arrowJS, extraJS := ArrowheadJS(r, connection.SrcArrow, connection.Stroke, connection.StrokeWidth)
|
arrowJS, extraJS := ArrowheadJS(r, bgColor, connection.SrcArrow, connection.Stroke, connection.StrokeWidth)
|
||||||
if arrowJS == "" {
|
if arrowJS == "" {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
@ -694,7 +697,7 @@ func Arrowheads(r *Runner, connection d2target.Connection, srcAdj, dstAdj *geo.P
|
||||||
}
|
}
|
||||||
|
|
||||||
if connection.DstArrow != d2target.NoArrowhead {
|
if connection.DstArrow != d2target.NoArrowhead {
|
||||||
arrowJS, extraJS := ArrowheadJS(r, connection.DstArrow, connection.Stroke, connection.StrokeWidth)
|
arrowJS, extraJS := ArrowheadJS(r, bgColor, connection.DstArrow, connection.Stroke, connection.StrokeWidth)
|
||||||
if arrowJS == "" {
|
if arrowJS == "" {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -489,7 +489,7 @@ func drawConnection(writer io.Writer, bgColor string, fgColor string, labelMaskI
|
||||||
fmt.Fprint(writer, out)
|
fmt.Fprint(writer, out)
|
||||||
|
|
||||||
// render sketch arrowheads separately
|
// render sketch arrowheads separately
|
||||||
arrowPaths, err := d2sketch.Arrowheads(sketchRunner, connection, srcAdj, dstAdj)
|
arrowPaths, err := d2sketch.Arrowheads(sketchRunner, bgColor, connection, srcAdj, dstAdj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
@ -994,7 +994,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske
|
||||||
|
|
||||||
addAppendixItems(writer, targetShape)
|
addAppendixItems(writer, targetShape)
|
||||||
|
|
||||||
fmt.Fprintf(writer, closingTag)
|
fmt.Fprint(writer, closingTag)
|
||||||
return labelMask, nil
|
return labelMask, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue