summaryrefslogtreecommitdiff
path: root/src/WWW/Colors/Instances.hs
diff options
context:
space:
mode:
authorChris Wells <chris@mathematicaster.org>2025-02-03 16:24:25 -0600
committerChris Wells <chris@mathematicaster.org>2025-02-03 16:24:25 -0600
commitf2a3c23634c7a5f8c23f68f24ff5dde95d472e16 (patch)
treed60ac3cb766075a4d16a496a90f2726ef7b4d132 /src/WWW/Colors/Instances.hs
parentc9cc52175073c5e690ea7eb30aad23d0d1776435 (diff)
downloadassets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.tar
assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.tar.gz
assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.tar.bz2
assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.tar.lz
assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.tar.xz
assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.tar.zst
assets-f2a3c23634c7a5f8c23f68f24ff5dde95d472e16.zip
Working on assets
Diffstat (limited to 'src/WWW/Colors/Instances.hs')
-rw-r--r--src/WWW/Colors/Instances.hs6
1 files changed, 5 insertions, 1 deletions
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