feat: class border-radius
This commit is contained in:
parent
fc4ff9c523
commit
22b14dcff7
1 changed files with 6 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ package d2svg
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"oss.terrastruct.com/d2/d2target"
|
"oss.terrastruct.com/d2/d2target"
|
||||||
"oss.terrastruct.com/d2/d2themes"
|
"oss.terrastruct.com/d2/d2themes"
|
||||||
|
|
@ -18,6 +19,9 @@ func classHeader(shape d2target.Shape, box *geo.Box, text string, textWidth, tex
|
||||||
rectEl.Fill = shape.Fill
|
rectEl.Fill = shape.Fill
|
||||||
rectEl.ClassName = "class_header"
|
rectEl.ClassName = "class_header"
|
||||||
str := rectEl.Render()
|
str := rectEl.Render()
|
||||||
|
if shape.BorderRadius != 0 {
|
||||||
|
str = strings.Replace(str, "/>", fmt.Sprintf(`clip-path="url(#%v)" />`, shape.ID), 1)
|
||||||
|
}
|
||||||
|
|
||||||
if text != "" {
|
if text != "" {
|
||||||
tl := label.InsideMiddleCenter.GetPointOnBox(
|
tl := label.InsideMiddleCenter.GetPointOnBox(
|
||||||
|
|
@ -89,6 +93,8 @@ func drawClass(writer io.Writer, targetShape d2target.Shape) {
|
||||||
el.Height = float64(targetShape.Height)
|
el.Height = float64(targetShape.Height)
|
||||||
el.Fill, el.Stroke = d2themes.ShapeTheme(targetShape)
|
el.Fill, el.Stroke = d2themes.ShapeTheme(targetShape)
|
||||||
el.Style = targetShape.CSSStyle()
|
el.Style = targetShape.CSSStyle()
|
||||||
|
el.Rx = float64(targetShape.BorderRadius)
|
||||||
|
el.Ry = float64(targetShape.BorderRadius)
|
||||||
fmt.Fprint(writer, el.Render())
|
fmt.Fprint(writer, el.Render())
|
||||||
|
|
||||||
box := geo.NewBox(
|
box := geo.NewBox(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue