module Data.Colour.CIE.Chromaticity where
data Chromaticity a = Chroma !a !a deriving (Chromaticity a -> Chromaticity a -> Bool
forall a. Eq a => Chromaticity a -> Chromaticity a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Chromaticity a -> Chromaticity a -> Bool
$c/= :: forall a. Eq a => Chromaticity a -> Chromaticity a -> Bool
== :: Chromaticity a -> Chromaticity a -> Bool
$c== :: forall a. Eq a => Chromaticity a -> Chromaticity a -> Bool
Eq)
mkChromaticity :: (Fractional a) => a -> a -> Chromaticity a
mkChromaticity :: forall a. Fractional a => a -> a -> Chromaticity a
mkChromaticity = forall a. a -> a -> Chromaticity a
Chroma
chromaCoords :: (Fractional a) => Chromaticity a -> (a, a, a)
chromaCoords :: forall a. Fractional a => Chromaticity a -> (a, a, a)
chromaCoords (Chroma a
x a
y) = (a
x, a
y, a
1 forall a. Num a => a -> a -> a
- a
x forall a. Num a => a -> a -> a
- a
y)
chromaX :: (Fractional a) => Chromaticity a -> a
chromaX :: forall a. Fractional a => Chromaticity a -> a
chromaX (Chroma a
x a
_y) = a
x
chromaY :: (Fractional a) => Chromaticity a -> a
chromaY :: forall a. Fractional a => Chromaticity a -> a
chromaY (Chroma a
_x a
y) = a
y
chromaZ :: (Fractional a) => Chromaticity a -> a
chromaZ :: forall a. Fractional a => Chromaticity a -> a
chromaZ (Chroma a
x a
y) = a
1 forall a. Num a => a -> a -> a
- a
x forall a. Num a => a -> a -> a
- a
y
chromaConvert :: (Fractional b, Real a) => Chromaticity a -> Chromaticity b
chromaConvert :: forall b a.
(Fractional b, Real a) =>
Chromaticity a -> Chromaticity b
chromaConvert (Chroma a
x a
y) = forall a. a -> a -> Chromaticity a
Chroma (forall a b. (Real a, Fractional b) => a -> b
realToFrac a
x) (forall a b. (Real a, Fractional b) => a -> b
realToFrac a
y)
instance (Fractional a, Show a) => Show (Chromaticity a) where
showsPrec :: Int -> Chromaticity a -> ShowS
showsPrec Int
d Chromaticity a
c = Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
app_prec) ShowS
showStr
where
showStr :: ShowS
showStr = String -> ShowS
showString String
"mkChromaticity " forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Show a => Int -> a -> ShowS
showsPrec (Int
app_precforall a. Num a => a -> a -> a
+Int
1) a
x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" " forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Show a => Int -> a -> ShowS
showsPrec (Int
app_precforall a. Num a => a -> a -> a
+Int
1) a
y)
(a
x,a
y,a
z) = forall a. Fractional a => Chromaticity a -> (a, a, a)
chromaCoords Chromaticity a
c
instance (Fractional a, Read a) => Read (Chromaticity a) where
readsPrec :: Int -> ReadS (Chromaticity a)
readsPrec Int
d String
r = forall a. Bool -> ReadS a -> ReadS a
readParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
app_prec)
(\String
r -> [(forall a. Fractional a => a -> a -> Chromaticity a
mkChromaticity a
x a
y,String
t)
|(String
"mkChromaticity",String
s) <- ReadS String
lex String
r
,(a
x,String
s0) <- forall a. Read a => Int -> ReadS a
readsPrec (Int
app_precforall a. Num a => a -> a -> a
+Int
1) String
s
,(a
y,String
t) <- forall a. Read a => Int -> ReadS a
readsPrec (Int
app_precforall a. Num a => a -> a -> a
+Int
1) String
s0]) String
r
app_prec :: Int
app_prec = Int
10
infix_prec :: Int
infix_prec = Int
9 forall a. a -> a -> a
`asTypeOf` Int
app_prec