implemented (limited) darkening of theme colors and fixed rendering of the 3D box
This commit is contained in:
parent
a972b5b0ee
commit
84e8c25e37
2 changed files with 33 additions and 7 deletions
|
|
@ -618,6 +618,7 @@ func render3dRect(targetShape d2target.Shape) string {
|
||||||
)
|
)
|
||||||
border := svg_style.NewThemableElement("path")
|
border := svg_style.NewThemableElement("path")
|
||||||
border.D = strings.Join(borderSegments, " ")
|
border.D = strings.Join(borderSegments, " ")
|
||||||
|
border.Fill = color.None
|
||||||
_, borderStroke := svg_style.ShapeTheme(targetShape)
|
_, borderStroke := svg_style.ShapeTheme(targetShape)
|
||||||
border.Stroke = borderStroke
|
border.Stroke = borderStroke
|
||||||
borderStyle := svg_style.ShapeStyle(targetShape)
|
borderStyle := svg_style.ShapeStyle(targetShape)
|
||||||
|
|
@ -646,6 +647,7 @@ func render3dRect(targetShape d2target.Shape) string {
|
||||||
mainShape.Mask = fmt.Sprintf("url(#%s)", maskID)
|
mainShape.Mask = fmt.Sprintf("url(#%s)", maskID)
|
||||||
mainShapeFill, _ := svg_style.ShapeTheme(targetShape)
|
mainShapeFill, _ := svg_style.ShapeTheme(targetShape)
|
||||||
mainShape.Fill = mainShapeFill
|
mainShape.Fill = mainShapeFill
|
||||||
|
mainShape.Stroke = color.None
|
||||||
mainShape.Style = svg_style.ShapeStyle(targetShape)
|
mainShape.Style = svg_style.ShapeStyle(targetShape)
|
||||||
mainShapeRendered := mainShape.Render()
|
mainShapeRendered := mainShape.Render()
|
||||||
|
|
||||||
|
|
@ -663,18 +665,17 @@ func render3dRect(targetShape d2target.Shape) string {
|
||||||
fmt.Sprintf("%d,%d", v.X+targetShape.Pos.X, v.Y+targetShape.Pos.Y),
|
fmt.Sprintf("%d,%d", v.X+targetShape.Pos.X, v.Y+targetShape.Pos.Y),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// TODO make darker color part of the theme?
|
// TODO make darker color part of the theme? or just keep this bypass
|
||||||
darkerColor := targetShape.Fill
|
darkerColor, err := color.Darken(targetShape.Fill)
|
||||||
// darkerColor, err := color.Darken(targetShape.Fill)
|
if err != nil {
|
||||||
// if err != nil {
|
darkerColor = targetShape.Fill
|
||||||
// darkerColor = targetShape.Fill
|
}
|
||||||
// }
|
|
||||||
sideShape := svg_style.NewThemableElement("polygon")
|
sideShape := svg_style.NewThemableElement("polygon")
|
||||||
sideShape.Fill = darkerColor
|
sideShape.Fill = darkerColor
|
||||||
sideShape.Points = strings.Join(sidePoints, " ")
|
sideShape.Points = strings.Join(sidePoints, " ")
|
||||||
sideShape.Mask = fmt.Sprintf("url(#%s)", maskID)
|
sideShape.Mask = fmt.Sprintf("url(#%s)", maskID)
|
||||||
sideShape.Style = svg_style.ShapeStyle(targetShape)
|
sideShape.Style = svg_style.ShapeStyle(targetShape)
|
||||||
renderedSides := mainShape.Render()
|
renderedSides := sideShape.Render()
|
||||||
|
|
||||||
return borderMask + mainShapeRendered + renderedSides + renderedBorder
|
return borderMask + mainShapeRendered + renderedSides + renderedBorder
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,36 @@
|
||||||
package color
|
package color
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"github.com/lucasb-eyer/go-colorful"
|
"github.com/lucasb-eyer/go-colorful"
|
||||||
"github.com/mazznoer/csscolorparser"
|
"github.com/mazznoer/csscolorparser"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var themeRegex = regexp.MustCompile("^B[1-6]$")
|
||||||
|
|
||||||
func Darken(colorString string) (string, error) {
|
func Darken(colorString string) (string, error) {
|
||||||
|
if themeRegex.MatchString(colorString) {
|
||||||
|
switch colorString[1] {
|
||||||
|
case '1':
|
||||||
|
return B1, nil
|
||||||
|
case '2':
|
||||||
|
return B1, nil
|
||||||
|
case '3':
|
||||||
|
return B2, nil
|
||||||
|
case '4':
|
||||||
|
return B3, nil
|
||||||
|
case '5':
|
||||||
|
return B4, nil
|
||||||
|
case '6':
|
||||||
|
return B5, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DarkenCSS(colorString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func DarkenCSS(colorString string) (string, error) {
|
||||||
c, err := csscolorparser.Parse(colorString)
|
c, err := csscolorparser.Parse(colorString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue