added missing colors conversion

This commit is contained in:
Vojtěch Fošnár 2023-01-12 11:19:34 +01:00
parent 2f9aad07f4
commit 19c53d5185
No known key found for this signature in database
GPG key ID: 657727E71C40859A
2 changed files with 77 additions and 17 deletions

View file

@ -1336,6 +1336,7 @@ func singleThemeRulesets(themeID int64) (rulesets string, err error) {
)
// Sketch style specific rulesets
// B
lc, err := color.LuminanceCategory(theme.Colors.B1)
if err != nil {
return "", err
@ -1367,6 +1368,36 @@ func singleThemeRulesets(themeID int64) (rulesets string, err error) {
}
out += fmt.Sprintf(".sketch-overlay-%s{fill:url(#streaks-%s);mix-blend-mode:%s}", color.B6, lc, blendMode(lc))
// AA
lc, err = color.LuminanceCategory(theme.Colors.AA2)
if err != nil {
return "", err
}
out += fmt.Sprintf(".sketch-overlay-%s{fill:url(#streaks-%s);mix-blend-mode:%s}", color.AA2, lc, blendMode(lc))
lc, err = color.LuminanceCategory(theme.Colors.AA4)
if err != nil {
return "", err
}
out += fmt.Sprintf(".sketch-overlay-%s{fill:url(#streaks-%s);mix-blend-mode:%s}", color.AA4, lc, blendMode(lc))
lc, err = color.LuminanceCategory(theme.Colors.AA5)
if err != nil {
return "", err
}
out += fmt.Sprintf(".sketch-overlay-%s{fill:url(#streaks-%s);mix-blend-mode:%s}", color.AA5, lc, blendMode(lc))
// AB
lc, err = color.LuminanceCategory(theme.Colors.AB4)
if err != nil {
return "", err
}
out += fmt.Sprintf(".sketch-overlay-%s{fill:url(#streaks-%s);mix-blend-mode:%s}", color.AB4, lc, blendMode(lc))
lc, err = color.LuminanceCategory(theme.Colors.AB5)
if err != nil {
return "", err
}
out += fmt.Sprintf(".sketch-overlay-%s{fill:url(#streaks-%s);mix-blend-mode:%s}", color.AB5, lc, blendMode(lc))
// Neutrals
lc, err = color.LuminanceCategory(theme.Colors.Neutrals.N1)
if err != nil {
return "", err
@ -1403,8 +1434,6 @@ func singleThemeRulesets(themeID int64) (rulesets string, err error) {
}
out += fmt.Sprintf(".sketch-overlay-%s{fill:url(#streaks-%s);mix-blend-mode:%s}", color.N7, lc, blendMode(lc))
// TODO Add the rest of the colors so we can allow the user to specify theme colors too
return out, nil
}

View file

@ -16,22 +16,53 @@ func IsThemeColor(colorString string) bool {
func Darken(colorString string) (string, error) {
if IsThemeColor(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
default:
return "", fmt.Errorf("darkening color \"%s\" is not yet supported", colorString) // TODO Add the rest of the colors so we can allow the user to specify theme colors too
switch {
case colorString[0] == 'B':
switch colorString[1] {
case '1', '2':
return B1, nil
case '3':
return B2, nil
case '4':
return B3, nil
case '5':
return B4, nil
case '6':
return B5, nil
}
case colorString[0:2] == "AA":
switch colorString[2] {
case '2', '4':
return AA2, nil
case '5':
return AA4, nil
}
case colorString[0:2] == "AB":
switch colorString[2] {
case '4', '5':
return AB4, nil
}
case colorString[0] == 'N':
switch colorString[1] {
case '1', '2':
return N1, nil
case '3':
return N2, nil
case '4':
return N3, nil
case '5':
return N4, nil
case '6':
return N5, nil
case '7':
return N6, nil
}
}
return "", fmt.Errorf("invalid color \"%s\"", colorString)
}
return darkenCSS(colorString)