summaryrefslogtreecommitdiff
path: root/src/WWW/Colors/Instances.hs
diff options
context:
space:
mode:
authorChris Wells <chris@mathematicaster.org>2024-12-04 13:23:40 -0600
committerChris Wells <chris@mathematicaster.org>2024-12-04 13:23:40 -0600
commitc9cc52175073c5e690ea7eb30aad23d0d1776435 (patch)
treea9fe3508fc60e3909ebe6a65dc77b44c367342d7 /src/WWW/Colors/Instances.hs
parentd7be39cd8a16e22f6f8784fdae06c223df5864c1 (diff)
downloadassets-c9cc52175073c5e690ea7eb30aad23d0d1776435.tar
assets-c9cc52175073c5e690ea7eb30aad23d0d1776435.tar.gz
assets-c9cc52175073c5e690ea7eb30aad23d0d1776435.tar.bz2
assets-c9cc52175073c5e690ea7eb30aad23d0d1776435.tar.lz
assets-c9cc52175073c5e690ea7eb30aad23d0d1776435.tar.xz
assets-c9cc52175073c5e690ea7eb30aad23d0d1776435.tar.zst
assets-c9cc52175073c5e690ea7eb30aad23d0d1776435.zip
Trying to write css
Diffstat (limited to 'src/WWW/Colors/Instances.hs')
-rw-r--r--src/WWW/Colors/Instances.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/WWW/Colors/Instances.hs b/src/WWW/Colors/Instances.hs
index e071b6b..3fc7667 100644
--- a/src/WWW/Colors/Instances.hs
+++ b/src/WWW/Colors/Instances.hs
@@ -1,23 +1,23 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
module WWW.Colors.Instances where
import Clay.Color qualified as Clay
import Data.Colour
import Data.Colour.SRGB (toSRGB24, sRGB24, RGB (..))
import Diagrams.Attributes
-import GHC.Float (double2Float, float2Double)
+-- | Not perfect, but good enough for building what I need
instance Color Clay.Color where
toAlphaColour :: Clay.Color -> AlphaColour Double
toAlphaColour col = case Clay.toRgba col of
Clay.Rgba r g b a ->
let rgb = sRGB24 (fromInteger r) (fromInteger g) (fromInteger b)
- in withOpacity rgb (float2Double a)
+ in alphaColourConvert $ withOpacity rgb a
_ -> error "Should not happen"
fromAlphaColour :: AlphaColour Double -> Clay.Color
fromAlphaColour col =
- let c = fromAlphaColour col :: Colour Double
- a = alphaChannel col
- rgb = toInteger <$> toSRGB24 c
- in Clay.rgba (channelRed rgb) (channelGreen rgb) (channelBlue rgb) (double2Float a)
+ let a = alphaChannel $ alphaColourConvert col
+ RGB r g b = toInteger <$> toSRGB24 (fromAlphaColour @(Colour Double) col)
+ in Clay.rgba r g b a