tins2021/colors.go

35 lines
729 B
Go
Raw Normal View History

package tins2021
import (
"image/color"
"github.com/lucasb-eyer/go-colorful"
)
var Blue = `#499BFF`
var Gray = `#E5E5E5`
var Green = `#9BFF49`
var Orange = `#FF9849`
var Purple = `#9E49FF`
var Red = `#FF4949`
var Yellow = `#FFEF49`
func Darken(hexColor string, lighten float64) string { return Lighten(hexColor, -lighten) }
func Lighten(hexColor string, lighten float64) string {
color := mustHexColor(hexColor)
h, c, l := color.Hcl()
lightened := colorful.Hcl(h, c, Clamp(l+lighten)).Clamped()
return lightened.Hex()
}
func mustHexColor(s string) colorful.Color {
c, err := colorful.Hex(s)
if err != nil {
panic("invalid color")
}
return c
}
func MustHexColor(s string) color.Color { return mustHexColor(s) }