{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- |
-- Module      : Graphics.Color.Space
-- Copyright   : (c) Alexey Kuleshevich 2018-2020
-- License     : BSD3
-- Maintainer  : Alexey Kuleshevich <lehins@yandex.ru>
-- Stability   : experimental
-- Portability : non-portable
--
module Graphics.Color.Space
  ( convertColor
  , convertColorFloat
  , module Graphics.Color.Space.RGB
  , module Graphics.Color.Space.Internal
  , module Graphics.Color.Space.CIE1976.LAB
  ) where

import Graphics.Color.Space.CIE1976.LAB
import Graphics.Color.Space.Internal
import Graphics.Color.Space.RGB


-- | Convert a color space through `XYZ` intermediary with `Double` precision. Illuminant is
-- enforced to be the same, but in case that it is a limitation and chromatic adaptation is
-- needed `Graphics.Color.Adaptation.convert` can be used instead.
--
-- @since 0.1.1
convertColor ::
     forall cs cs' i e. (ColorSpace cs' i e, ColorSpace cs i e)
  => Color cs' e
  -> Color cs e
convertColor :: Color cs' e -> Color cs e
convertColor = Color (XYZ i) Double -> Color cs e
forall k cs (i :: k) e a.
(ColorSpace cs i e, Elevator a, RealFloat a) =>
Color (XYZ i) a -> Color cs e
fromColorXYZ (Color (XYZ i) Double -> Color cs e)
-> (Color cs' e -> Color (XYZ i) Double)
-> Color cs' e
-> Color cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Color cs' e -> Color (XYZ i) Double
forall k cs (i :: k) e a.
(ColorSpace cs i e, Elevator a, RealFloat a) =>
Color cs e -> Color (XYZ i) a
toColorXYZ :: Color cs' e -> Color (XYZ i) Double)
{-# INLINE convertColor #-}

-- | Same as `convertColor`, but use 32bit `Float` as an intermediary precision
--
-- @since 0.1.1
convertColorFloat ::
     forall cs cs' i e. (ColorSpace cs' i e, ColorSpace cs i e)
  => Color cs' e
  -> Color cs e
convertColorFloat :: Color cs' e -> Color cs e
convertColorFloat = Color (XYZ i) Float -> Color cs e
forall k cs (i :: k) e a.
(ColorSpace cs i e, Elevator a, RealFloat a) =>
Color (XYZ i) a -> Color cs e
fromColorXYZ (Color (XYZ i) Float -> Color cs e)
-> (Color cs' e -> Color (XYZ i) Float)
-> Color cs' e
-> Color cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Color cs' e -> Color (XYZ i) Float
forall k cs (i :: k) e a.
(ColorSpace cs i e, Elevator a, RealFloat a) =>
Color cs e -> Color (XYZ i) a
toColorXYZ :: Color cs' e -> Color (XYZ i) Float)
{-# INLINE convertColorFloat #-}