seems to be working
This commit is contained in:
parent
a7f83f7029
commit
9544a48f80
3 changed files with 38 additions and 29 deletions
|
|
@ -635,12 +635,17 @@ func splitPath(path string, percentage float64) (string, string) {
|
||||||
heading2 := geo.Point{X: h2x, Y: h2y}
|
heading2 := geo.Point{X: h2x, Y: h2y}
|
||||||
nextPoint := geo.Point{X: p1x, Y: p1y}
|
nextPoint := geo.Point{X: p1x, Y: p1y}
|
||||||
|
|
||||||
_, q2, q3, q4 := splitBezierCurve(&prevPosition, &heading1, &heading2, &nextPoint, 0, 0.5)
|
q1, q2, q3, q4 := splitBezierCurve(&prevPosition, &heading1, &heading2, &nextPoint, 0, 0.5)
|
||||||
|
|
||||||
path1 += fmt.Sprintf("C %f %f %f %f %f %f ", q2.X, q2.Y, q3.X, q3.Y, q4.X, q4.Y);
|
path1 += fmt.Sprintf("C %f %f %f %f %f %f ", q2.X, q2.Y, q3.X, q3.Y, q4.X, q4.Y);
|
||||||
|
|
||||||
|
q1, q2, q3, q4 = splitBezierCurve(&prevPosition, &heading1, &heading2, &nextPoint, 0.5, 1)
|
||||||
|
|
||||||
|
path2 += fmt.Sprintf("M %f %f C %f %f %f %f %f %f ", q1.X, q1.Y, q2.X, q2.Y, q3.X, q3.Y, q4.X, q4.Y);
|
||||||
|
|
||||||
case "S":
|
case "S":
|
||||||
path1 += fmt.Sprintf("S %s %s %s %s ", pathData[i + 1], pathData[i + 2], pathData[i + 3], pathData[i + 4])
|
path1 += fmt.Sprintf("S %s %s %s %s ", pathData[i + 1], pathData[i + 2], pathData[i + 3], pathData[i + 4])
|
||||||
|
path2 += fmt.Sprintf("M %s %s ", pathData[i + 3], pathData[i + 4])
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("unknown svg path command \"%s\"", pathData[i]))
|
panic(fmt.Sprintf("unknown svg path command \"%s\"", pathData[i]))
|
||||||
}
|
}
|
||||||
|
|
@ -736,8 +741,6 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co
|
||||||
srcAdj, dstAdj := getArrowheadAdjustments(connection, idToShape)
|
srcAdj, dstAdj := getArrowheadAdjustments(connection, idToShape)
|
||||||
path := pathData(connection, srcAdj, dstAdj)
|
path := pathData(connection, srcAdj, dstAdj)
|
||||||
mask := fmt.Sprintf(`mask="url(#%s)"`, labelMaskID)
|
mask := fmt.Sprintf(`mask="url(#%s)"`, labelMaskID)
|
||||||
|
|
||||||
path1, path2 := splitPath(path, 0.5);
|
|
||||||
|
|
||||||
if sketchRunner != nil {
|
if sketchRunner != nil {
|
||||||
out, err := d2sketch.Connection(sketchRunner, connection, path, mask)
|
out, err := d2sketch.Connection(sketchRunner, connection, path, mask)
|
||||||
|
|
@ -758,32 +761,38 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co
|
||||||
animatedClass = " animated-connection"
|
animatedClass = " animated-connection"
|
||||||
}
|
}
|
||||||
|
|
||||||
pathEl := d2themes.NewThemableElement("path")
|
// if connection is not animated or is a directed connection
|
||||||
pathEl.D = path
|
if !connection.Animated || ((connection.DstArrow == d2target.NoArrowhead && connection.SrcArrow != d2target.NoArrowhead) || (connection.DstArrow != d2target.NoArrowhead && connection.SrcArrow == d2target.NoArrowhead)) {
|
||||||
pathEl.Fill = color.None
|
pathEl := d2themes.NewThemableElement("path")
|
||||||
pathEl.Stroke = connection.Stroke
|
pathEl.D = path
|
||||||
pathEl.ClassName = fmt.Sprintf("connection%s", animatedClass)
|
pathEl.Fill = color.None
|
||||||
pathEl.Style = connection.CSSStyle()
|
pathEl.Stroke = connection.Stroke
|
||||||
pathEl.Attributes = fmt.Sprintf("%s%s%s", markerStart, markerEnd, mask)
|
pathEl.ClassName = fmt.Sprintf("connection%s", animatedClass)
|
||||||
// fmt.Fprint(writer, pathEl.Render())
|
pathEl.Style = connection.CSSStyle()
|
||||||
|
pathEl.Attributes = fmt.Sprintf("%s%s%s", markerStart, markerEnd, mask)
|
||||||
|
fmt.Fprint(writer, pathEl.Render())
|
||||||
|
} else {
|
||||||
|
path1, path2 := splitPath(path, 0.5);
|
||||||
|
|
||||||
pathEl1 := d2themes.NewThemableElement("path")
|
pathEl1 := d2themes.NewThemableElement("path")
|
||||||
pathEl1.D = path1
|
pathEl1.D = path1
|
||||||
pathEl1.Fill = color.None
|
pathEl1.Fill = color.None
|
||||||
pathEl1.Stroke = connection.Stroke
|
pathEl1.Stroke = connection.Stroke
|
||||||
pathEl1.ClassName = fmt.Sprintf("connection%s", animatedClass)
|
pathEl1.ClassName = fmt.Sprintf("connection%s", animatedClass)
|
||||||
pathEl1.Style = connection.CSSStyle()
|
pathEl1.Style = connection.CSSStyle()
|
||||||
pathEl1.Attributes = fmt.Sprintf("%s%s%s", markerStart, markerEnd, mask)
|
pathEl1.Style += "animation-direction: reverse;"
|
||||||
fmt.Fprint(writer, pathEl1.Render())
|
pathEl1.Attributes = fmt.Sprintf("%s%s", markerStart, mask)
|
||||||
|
fmt.Fprint(writer, pathEl1.Render())
|
||||||
|
|
||||||
pathEl2 := d2themes.NewThemableElement("path")
|
pathEl2 := d2themes.NewThemableElement("path")
|
||||||
pathEl2.D = path2
|
pathEl2.D = path2
|
||||||
pathEl2.Fill = color.None
|
pathEl2.Fill = color.None
|
||||||
pathEl2.Stroke = connection.Stroke
|
pathEl2.Stroke = connection.Stroke
|
||||||
pathEl2.ClassName = fmt.Sprintf("connection%s", animatedClass)
|
pathEl2.ClassName = fmt.Sprintf("connection%s", animatedClass)
|
||||||
pathEl2.Style = connection.CSSStyle()
|
pathEl2.Style = connection.CSSStyle()
|
||||||
pathEl2.Attributes = fmt.Sprintf("%s%s%s", markerStart, markerEnd, mask)
|
pathEl2.Attributes = fmt.Sprintf("%s%s", markerEnd, mask)
|
||||||
fmt.Fprint(writer, pathEl2.Render())
|
fmt.Fprint(writer, pathEl2.Render())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if connection.Label != "" {
|
if connection.Label != "" {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Loading…
Reference in a new issue