From f2a3c23634c7a5f8c23f68f24ff5dde95d472e16 Mon Sep 17 00:00:00 2001 From: Chris Wells Date: Mon, 3 Feb 2025 16:24:25 -0600 Subject: Working on assets --- src/WWW/Colors/Instances.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/WWW/Colors/Instances.hs') diff --git a/src/WWW/Colors/Instances.hs b/src/WWW/Colors/Instances.hs index 3fc7667..3dd6e6a 100644 --- a/src/WWW/Colors/Instances.hs +++ b/src/WWW/Colors/Instances.hs @@ -2,6 +2,7 @@ module WWW.Colors.Instances where import Clay.Color qualified as Clay +import Clay.Property qualified as Clay import Data.Colour import Data.Colour.SRGB (toSRGB24, sRGB24, RGB (..)) import Diagrams.Attributes @@ -13,7 +14,7 @@ instance Color Clay.Color where toAlphaColour col = case Clay.toRgba col of Clay.Rgba r g b a -> let rgb = sRGB24 (fromInteger r) (fromInteger g) (fromInteger b) - in alphaColourConvert $ withOpacity rgb a + in alphaColourConvert $ rgb `withOpacity` a _ -> error "Should not happen" fromAlphaColour :: AlphaColour Double -> Clay.Color @@ -21,3 +22,6 @@ instance Color Clay.Color where let a = alphaChannel $ alphaColourConvert col RGB r g b = toInteger <$> toSRGB24 (fromAlphaColour @(Colour Double) col) in Clay.rgba r g b a + +instance Clay.Val SomeColor where + value = Clay.value . fromAlphaColour @Clay.Color . someToAlpha -- cgit v1.2.3