{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NegativeLiterals #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
module Graphics.Color.Model.RGB
( RGB
, pattern ColorRGB
, pattern ColorRGBA
, pattern RGB
, Color
, ColorModel(..)
) where
import Foreign.Storable
import Graphics.Color.Algebra
import Graphics.Color.Model.Internal
data RGB
newtype instance Color RGB e = RGB (V3 e)
pattern ColorRGB :: e -> e -> e -> Color RGB e
pattern $bColorRGB :: e -> e -> e -> Color RGB e
$mColorRGB :: forall r e. Color RGB e -> (e -> e -> e -> r) -> (Void# -> r) -> r
ColorRGB r g b = RGB (V3 r g b)
{-# COMPLETE ColorRGB #-}
pattern ColorRGBA :: e -> e -> e -> e -> Color (Alpha RGB) e
pattern $bColorRGBA :: e -> e -> e -> e -> Color (Alpha RGB) e
$mColorRGBA :: forall r e.
Color (Alpha RGB) e -> (e -> e -> e -> e -> r) -> (Void# -> r) -> r
ColorRGBA r g b a = Alpha (RGB (V3 r g b)) a
{-# COMPLETE ColorRGBA #-}
deriving instance Eq e => Eq (Color RGB e)
deriving instance Ord e => Ord (Color RGB e)
instance Elevator e => Show (Color RGB e) where
showsPrec :: Int -> Color RGB e -> ShowS
showsPrec Int
_ = Color RGB e -> ShowS
forall cs e. ColorModel cs e => Color cs e -> ShowS
showsColorModel
instance Elevator e => ColorModel RGB e where
type Components RGB e = (e, e, e)
toComponents :: Color RGB e -> Components RGB e
toComponents (ColorRGB e
r e
g e
b) = (e
r, e
g, e
b)
{-# INLINE toComponents #-}
fromComponents :: Components RGB e -> Color RGB e
fromComponents (r, g, b) = e -> e -> e -> Color RGB e
forall e. e -> e -> e -> Color RGB e
ColorRGB e
r e
g e
b
{-# INLINE fromComponents #-}
deriving instance Functor (Color RGB)
deriving instance Applicative (Color RGB)
deriving instance Foldable (Color RGB)
deriving instance Traversable (Color RGB)
deriving instance Storable e => Storable (Color RGB e)