sketch
sketch copied to clipboard
add color functions
I'm thinking of:
import sketch/color
// Something like this with contructors
type Color {
Named(String)
Hex(String)
Rgb(Int, Int, Int)
Rgba(Int, Int, Int, Float)
Hsl(Int, Float, Float)
}
sketch.class([
sketch.background(
color.named("red")
|> color.alpha(0.5)
|> color.darken(0.2)
|> color.to_hsl_string()
)
])
sketch.class([
sketch.background(
color.rgba(r: 255, g: 255, b: 255, alpha: 0.1)
|> color.alpha(0.5)
|> color.to_rgba_string() // rgba(255, 255, 255, 0.5)
)
])
sketch.class([
sketch.background(
color.rgba(r: 255, g: 0, b: 0, alpha: 1)
|> color.to_hex_string() // "#FF0000
)
])
color.hex("FFF")
|> color.alpha(0.5)
|> color.to_hex_string() |> // rgba(255, 255, 255, 0.5)
)
But let's discuss the API