@@ -41,6 +41,33 @@ func clipPathForBorderRadius(diagramHash string, shape d2target.Shape) string {
41
41
return out + `fill="none" /> </clipPath>`
42
42
}
43
43
44
+ func clipPathForIconBorderRadius (diagramHash string , shape d2target.Shape ) string {
45
+ box := geo .NewBox (
46
+ geo .NewPoint (float64 (shape .Pos .X ), float64 (shape .Pos .Y )),
47
+ float64 (shape .Width ),
48
+ float64 (shape .Height ),
49
+ )
50
+ topX , topY := box .TopLeft .X + box .Width , box .TopLeft .Y
51
+
52
+ out := fmt .Sprintf (`<clipPath id="%v-%v-icon">` , diagramHash , shape .ID )
53
+ out += fmt .Sprintf (`<path d="M %f %f L %f %f S %f %f %f %f ` , box .TopLeft .X , box .TopLeft .Y + float64 (shape .IconBorderRadius ), box .TopLeft .X , box .TopLeft .Y + float64 (shape .IconBorderRadius ), box .TopLeft .X , box .TopLeft .Y , box .TopLeft .X + float64 (shape .IconBorderRadius ), box .TopLeft .Y )
54
+ out += fmt .Sprintf (`L %f %f L %f %f ` , box .TopLeft .X + box .Width - float64 (shape .IconBorderRadius ), box .TopLeft .Y , topX - float64 (shape .IconBorderRadius ), topY )
55
+
56
+ out += fmt .Sprintf (`S %f %f %f %f ` , topX , topY , topX , topY + float64 (shape .IconBorderRadius ))
57
+ out += fmt .Sprintf (`L %f %f ` , topX , topY + box .Height - float64 (shape .IconBorderRadius ))
58
+
59
+ if len (shape .Columns ) != 0 {
60
+ out += fmt .Sprintf (`L %f %f L %f %f` , topX , topY + box .Height , box .TopLeft .X , box .TopLeft .Y + box .Height )
61
+ } else {
62
+ out += fmt .Sprintf (`S %f % f %f %f ` , topX , topY + box .Height , topX - float64 (shape .IconBorderRadius ), topY + box .Height )
63
+ out += fmt .Sprintf (`L %f %f ` , box .TopLeft .X + float64 (shape .IconBorderRadius ), box .TopLeft .Y + box .Height )
64
+ out += fmt .Sprintf (`S %f %f %f %f` , box .TopLeft .X , box .TopLeft .Y + box .Height , box .TopLeft .X , box .TopLeft .Y + box .Height - float64 (shape .IconBorderRadius ))
65
+ out += fmt .Sprintf (`L %f %f` , box .TopLeft .X , box .TopLeft .Y + float64 (shape .IconBorderRadius ))
66
+ }
67
+ out += fmt .Sprintf (`Z %f %f" ` , box .TopLeft .X , box .TopLeft .Y )
68
+ return out + `fill="none" /> </clipPath>`
69
+ }
70
+
44
71
func tableHeader (diagramHash string , shape d2target.Shape , box * geo.Box , text string , textWidth , textHeight , fontSize float64 , inlineTheme * d2themes.Theme ) string {
45
72
rectEl := d2themes .NewThemableElement ("rect" , inlineTheme )
46
73
rectEl .X , rectEl .Y = box .TopLeft .X , box .TopLeft .Y
0 commit comments