set transparent labelMask for shapes
This commit is contained in:
parent
0fbcf48d7c
commit
4373d81e84
1 changed files with 10 additions and 4 deletions
|
|
@ -456,11 +456,16 @@ func pathData(connection d2target.Connection, srcAdj, dstAdj *geo.Point) string
|
||||||
return strings.Join(path, " ")
|
return strings.Join(path, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeLabelMask(labelTL *geo.Point, width, height int) string {
|
func makeLabelMask(labelTL *geo.Point, width, height int, opacity float64) string {
|
||||||
return fmt.Sprintf(`<rect x="%f" y="%f" width="%d" height="%d" fill="black"></rect>`,
|
fill := "black"
|
||||||
|
if opacity != 1 {
|
||||||
|
fill = fmt.Sprintf("rgba(0,0,0,%.2f)", opacity)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf(`<rect x="%f" y="%f" width="%d" height="%d" fill="%s"></rect>`,
|
||||||
labelTL.X, labelTL.Y,
|
labelTL.X, labelTL.Y,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
|
fill,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -510,7 +515,7 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co
|
||||||
labelTL.Y = math.Round(labelTL.Y)
|
labelTL.Y = math.Round(labelTL.Y)
|
||||||
|
|
||||||
if label.Position(connection.LabelPosition).IsOnEdge() {
|
if label.Position(connection.LabelPosition).IsOnEdge() {
|
||||||
labelMask = makeLabelMask(labelTL, connection.LabelWidth, connection.LabelHeight)
|
labelMask = makeLabelMask(labelTL, connection.LabelWidth, connection.LabelHeight, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1206,6 +1211,7 @@ func drawShape(writer io.Writer, diagramHash string, targetShape d2target.Shape,
|
||||||
float64(targetShape.LabelWidth),
|
float64(targetShape.LabelWidth),
|
||||||
float64(targetShape.LabelHeight),
|
float64(targetShape.LabelHeight),
|
||||||
)
|
)
|
||||||
|
labelMask = makeLabelMask(labelTL, targetShape.LabelWidth, targetShape.LabelHeight, 0.95)
|
||||||
|
|
||||||
fontClass := "text"
|
fontClass := "text"
|
||||||
if targetShape.FontFamily == "mono" {
|
if targetShape.FontFamily == "mono" {
|
||||||
|
|
@ -1324,7 +1330,7 @@ func drawShape(writer io.Writer, diagramHash string, targetShape d2target.Shape,
|
||||||
textEl.Content = RenderText(targetShape.Label, textEl.X, float64(targetShape.LabelHeight))
|
textEl.Content = RenderText(targetShape.Label, textEl.X, float64(targetShape.LabelHeight))
|
||||||
fmt.Fprint(writer, textEl.Render())
|
fmt.Fprint(writer, textEl.Render())
|
||||||
if targetShape.Blend {
|
if targetShape.Blend {
|
||||||
labelMask = makeLabelMask(labelTL, targetShape.LabelWidth, targetShape.LabelHeight-d2graph.INNER_LABEL_PADDING)
|
labelMask = makeLabelMask(labelTL, targetShape.LabelWidth, targetShape.LabelHeight-d2graph.INNER_LABEL_PADDING, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue