packages feed

Color 0.1.3.1 → 0.1.4

raw patch · 30 files changed

+287/−207 lines, 30 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Graphics.Color.Space.RGB.Luma: instance GHC.Base.Functor (Graphics.Color.Space.RGB.Luma.Weight cs)
- Graphics.Color.Space.RGB.Luma: instance GHC.Classes.Eq e => GHC.Classes.Eq (Graphics.Color.Space.RGB.Luma.Weight cs e)
- Graphics.Color.Space.RGB.Luma: instance GHC.Float.Floating e => GHC.Float.Floating (Graphics.Color.Space.RGB.Luma.Weight cs e)
- Graphics.Color.Space.RGB.Luma: instance GHC.Num.Num e => GHC.Num.Num (Graphics.Color.Space.RGB.Luma.Weight cs e)
- Graphics.Color.Space.RGB.Luma: instance GHC.Real.Fractional e => GHC.Real.Fractional (Graphics.Color.Space.RGB.Luma.Weight cs e)
- Graphics.Color.Space.RGB.Luma: instance GHC.Show.Show e => GHC.Show.Show (Graphics.Color.Space.RGB.Luma.Weight cs e)
- Graphics.Color.Space.RGB.Luma: pattern Y' :: () => e -> Color Y' e
+ Graphics.Color.Space.RGB.Luma: instance forall k (cs :: k) e. GHC.Classes.Eq e => GHC.Classes.Eq (Graphics.Color.Space.RGB.Luma.Weight cs e)
+ Graphics.Color.Space.RGB.Luma: instance forall k (cs :: k) e. GHC.Float.Floating e => GHC.Float.Floating (Graphics.Color.Space.RGB.Luma.Weight cs e)
+ Graphics.Color.Space.RGB.Luma: instance forall k (cs :: k) e. GHC.Num.Num e => GHC.Num.Num (Graphics.Color.Space.RGB.Luma.Weight cs e)
+ Graphics.Color.Space.RGB.Luma: instance forall k (cs :: k) e. GHC.Real.Fractional e => GHC.Real.Fractional (Graphics.Color.Space.RGB.Luma.Weight cs e)
+ Graphics.Color.Space.RGB.Luma: instance forall k (cs :: k) e. GHC.Show.Show e => GHC.Show.Show (Graphics.Color.Space.RGB.Luma.Weight cs e)
+ Graphics.Color.Space.RGB.Luma: instance forall k (cs :: k). GHC.Base.Functor (Graphics.Color.Space.RGB.Luma.Weight cs)
+ Graphics.Color.Space.RGB.Luma: pattern Luma :: () => Color Y e -> Color Y' e
+ Graphics.Color.Space.RGB.Luma: pattern Y' :: e -> Color Y' e
+ Graphics.Color.Space.RGB.Luma: pattern Y'A :: e -> e -> Color (Alpha Y') e
+ Graphics.Pixel: pixelColor :: Pixel cs e -> Color cs e
+ Graphics.Pixel.ColorSpace: pattern PixelY' :: e -> Pixel Y' e
+ Graphics.Pixel.ColorSpace: pattern PixelY'A :: e -> e -> Pixel (Alpha Y') e
+ Graphics.Pixel.ColorSpace: pixelColor :: Pixel cs e -> Color cs e
+ Graphics.Pixel.ColorSpace: rgbPixelLuma :: forall cs i e' e. (Luma cs, RedGreenBlue cs i, Elevator e', Elevator e, RealFloat e) => Pixel cs e' -> Pixel Y' e
- Graphics.Color.Model: class (Functor (Color cs), Applicative (Color cs), Foldable (Color cs), Traversable (Color cs), Eq (Color cs e), Show (Color cs e), Unbox (Components cs e), Storable (Color cs e), Typeable cs, Elevator e) => ColorModel cs e where {
+ Graphics.Color.Model: class (Functor (Color cs), Applicative (Color cs), Foldable (Color cs), Traversable (Color cs), Eq (Color cs e), Show (Color cs e), Unbox (Components cs e), Storable (Color cs e), Typeable cs, Elevator e, Typeable (Opaque cs)) => ColorModel cs e where {
- Graphics.Color.Space: class (Functor (Color cs), Applicative (Color cs), Foldable (Color cs), Traversable (Color cs), Eq (Color cs e), Show (Color cs e), Unbox (Components cs e), Storable (Color cs e), Typeable cs, Elevator e) => ColorModel cs e where {
+ Graphics.Color.Space: class (Functor (Color cs), Applicative (Color cs), Foldable (Color cs), Traversable (Color cs), Eq (Color cs e), Show (Color cs e), Unbox (Components cs e), Storable (Color cs e), Typeable cs, Elevator e, Typeable (Opaque cs)) => ColorModel cs e where {
- Graphics.Color.Space: class (Illuminant i, ColorModel (BaseModel cs) e, ColorModel cs e, Typeable (Opaque cs)) => ColorSpace cs (i :: k) e | cs -> i where {
+ Graphics.Color.Space: class (Illuminant i, ColorModel (BaseModel cs) e, ColorModel cs e) => ColorSpace cs (i :: k) e | cs -> i where {
- Graphics.Color.Space: data family Color cs e :: Type
+ Graphics.Color.Space: data family Vector a :: Type
- Graphics.Color.Space: type family Components cs e :: Type;
+ Graphics.Color.Space: type family Opaque cs

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog for color +## 0.1.4++* Export `pixelColor`+* Add luma related patterns: `PixelY'`, `PixelY'A`, `Y'` and `Y'A`. Also `rgbPixelLuma`+ ## 0.1.3.1  * Fix introduced in `0.1.2` for `Alpha cs` was incomplete and is fixed in this version
Color.cabal view
@@ -1,5 +1,5 @@ name:                Color-version:             0.1.3.1+version:             0.1.4 synopsis:            Color spaces and conversions between them description:         Please see the README on GitHub at <https://github.com/lehins/Color#readme> homepage:            https://github.com/lehins/Color@@ -79,7 +79,6 @@                      , Graphics.Color.Algebra.Elevator                      , Graphics.Color.Model.CMYK                      , Graphics.Color.Model.Internal-                     , Graphics.Color.Model.Alpha                      , Graphics.Color.Model.RGB                      , Graphics.Color.Model.HSI                      , Graphics.Color.Model.HSL
README.md view
@@ -1,3 +1,76 @@ # Color -See the repository for proper introduction: https://github.com/lehins/Color+| Language | Travis | Coveralls |Gitter.im |+|:--------:|:------:|:---------:|:--------:|+| ![GitHub top language](https://img.shields.io/github/languages/top/lehins/Color.svg) | [![Travis](https://img.shields.io/travis/lehins/Color/master.svg?label=Linux%20%26%20OS%20X)](https://travis-ci.org/lehins/Color) | [![Coverage Status](https://coveralls.io/repos/github/lehins/Color/badge.svg?branch=master)](https://coveralls.io/github/lehins/Color?branch=master) | [![Join the chat at https://gitter.im/haskell-massiv/Lobby](https://badges.gitter.im/haskell-massiv/Lobby.svg)](https://gitter.im/haskell-massiv/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)++|      Package       | Hackage | Nightly | LTS |+|:-------------------|:-------:|:-------:|:---:|+|  [`Color`](https://github.com/lehins/Color/tree/master/Color)|                                       [![Hackage](https://img.shields.io/hackage/v/Color.svg)](https://hackage.haskell.org/package/Color)|                                                                                                        [![Nightly](https://www.stackage.org/package/Color/badge/nightly)](https://www.stackage.org/nightly/package/Color)|                                                                                         [![Nightly](https://www.stackage.org/package/Color/badge/lts)](https://www.stackage.org/lts/package/Color)|++A library for dealing with Colors and pixels. It implements arbitrary color space+conversion, chromatic adaptation and other color manipulations.++There is a clear separation between color models, color spaces and alternative+representations of color spaces. All are distinct at the type level. The goal is to+prevent mixups of incompatible color types as well as utilize type information for+conversion between them.++Currently supported:++* Color models:++  * `Y`+  * `RGB`+  * `HSI`+  * `HSL`+  * `HSV`+  * `YCbCr`+  * `CMYK`++* Color spaces and arbitrary conversions between them:++  * `Y` - luminance+  * `CIE XYZ`+  * `CIE L*a*b*`+  * `RGB`:++    * `sRGB`+    * `AdobeRGB`+    * ITU: `Rec470`, `Rec601` and `Rec709`+    * Alternative representations:++      * `HSI`+      * `HSL`+      * `HSV`+      * `YCbCr`+      * `CMYK`++* Illuminants:++  * CIE1931 - 2 degree observer+  * CIE1964 - 10 degree observer+  * Some common alternatives++* Chromatic adaptation:++  * VonKries adaptation with transformations:++      * VonKries+      * Bradford (default)+      * Fairchild+      * CIECAM02++* Color Standards:++  * RAL+++# External resources++* `Color` is on a list of curated [Awesome Colour](https://awesome-colour.org/#haskell)+  resources.++* While working on this library the [colour-science.org](https://www.colour-science.org/)+  and their Python implementation of [colour](https://github.com/colour-science/colour)+  was used extensively as a reference.
src/Graphics/Color/Model.hs view
@@ -36,7 +36,6 @@   , module Graphics.Color.Algebra.Elevator   ) where -import Graphics.Color.Model.Alpha import Graphics.Color.Model.CMYK import Graphics.Color.Model.HSI import Graphics.Color.Model.HSL
− src/Graphics/Color/Model/Alpha.hs
@@ -1,139 +0,0 @@-{-# LANGUAGE UndecidableInstances #-}-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilies #-}--- |--- Module      : Graphics.Color.Model.Alpha--- Copyright   : (c) Alexey Kuleshevich 2018-2019--- License     : BSD3--- Maintainer  : Alexey Kuleshevich <lehins@yandex.ru>--- Stability   : experimental--- Portability : non-portable----module Graphics.Color.Model.Alpha-  ( Alpha-  , Opaque-  , addAlpha-  , getAlpha-  , setAlpha-  , dropAlpha-  , modifyAlpha-  , modifyOpaque-  , Color(Alpha)-  , ColorModel(..)-  ) where--import Foreign.Ptr-import Foreign.Storable-import Graphics.Color.Model.Internal-import GHC.TypeLits-import Data.Proxy--data Alpha cs--data instance Color (Alpha cs) e = Alpha-  { _opaque :: !(Color cs e)-  , _alpha :: !e-  }---- | Get the alpha channel value for the pixel------ @since 0.1.0-getAlpha :: Color (Alpha cs) e -> e-getAlpha = _alpha-{-# INLINE getAlpha #-}---- | Get the opaque pixel value, while leaving alpha channel intact.------ @since 0.1.0-dropAlpha :: Color (Alpha cs) e -> Color cs e-dropAlpha = _opaque-{-# INLINE dropAlpha #-}---- | Add an alpha channel value to an opaque pixel------ @since 0.1.0-addAlpha :: Color cs e -> e -> Color (Alpha cs) e-addAlpha = Alpha-{-# INLINE addAlpha #-}---- | Change the alpha channel value for the pixel------ @since 0.1.0-setAlpha :: Color (Alpha cs) e -> e -> Color (Alpha cs) e-setAlpha px a = px { _alpha = a }-{-# INLINE setAlpha #-}---- | Change the alpha channel value for the pixel------ @since 0.1.0-modifyAlpha :: (e -> e) -> Color (Alpha cs) e -> Color (Alpha cs) e-modifyAlpha f px = px { _alpha = f (_alpha px) }-{-# INLINE modifyAlpha #-}---- | Change the opaque pixel value, while leaving alpha channel intact.------ @since 0.1.0-modifyOpaque :: (Color cs e -> Color cs' e) -> Color (Alpha cs) e -> Color (Alpha cs') e-modifyOpaque fpx pxa = pxa { _opaque = fpx (_opaque pxa) }-{-# INLINE modifyOpaque #-}--instance (Eq (Color cs e), Eq e) => Eq (Color (Alpha cs) e) where-  (==) (Alpha px1 a1) (Alpha px2 a2) = px1 == px2 && a1 == a2-  {-# INLINE (==) #-}--instance (ColorModel cs e, cs ~ Opaque (Alpha cs)) =>-         Show (Color (Alpha cs) e) where-  showsPrec _ = showsColorModel--type family Opaque cs where-  Opaque (Alpha (Alpha cs)) = TypeError ('Text "Nested alpha channels are not allowed")-  Opaque (Alpha cs) = cs-  Opaque cs = cs--instance (ColorModel cs e, cs ~ Opaque (Alpha cs)) =>-         ColorModel (Alpha cs) e where-  type Components (Alpha cs) e = (Components cs e, e)-  toComponents (Alpha px a) = (toComponents px, a)-  {-# INLINE toComponents #-}-  fromComponents (pxc, a) = Alpha (fromComponents pxc) a-  {-# INLINE fromComponents #-}-  showsColorModelName _ = ("Alpha (" ++) . showsColorModelName (Proxy :: Proxy (Color cs e)) . (')':)---instance Functor (Color cs) => Functor (Color (Alpha cs)) where-  fmap f (Alpha px a) = Alpha (fmap f px) (f a)-  {-# INLINE fmap #-}--instance Applicative (Color cs) => Applicative (Color (Alpha cs)) where-  pure e = Alpha (pure e) e-  {-# INLINE pure #-}-  (Alpha fpx fa) <*> (Alpha px a) = Alpha (fpx <*> px) (fa a)-  {-# INLINE (<*>) #-}--instance Foldable (Color cs) => Foldable (Color (Alpha cs)) where-  foldr f acc (Alpha px a) = foldr f (f a acc) px-  {-# INLINE foldr #-}-  foldr1 f (Alpha px a) = foldr f a px-  {-# INLINE foldr1 #-}--instance Traversable (Color cs) => Traversable (Color (Alpha cs)) where-  traverse f (Alpha px a) = Alpha <$> traverse f px <*> f a-  {-# INLINE traverse #-}--instance (Storable (Color cs e), Storable e) => Storable (Color (Alpha cs) e) where-  sizeOf _ = sizeOf (undefined :: Color cs e) + sizeOf (undefined :: e)-  {-# INLINE sizeOf #-}-  alignment _ = alignment (undefined :: e)-  {-# INLINE alignment #-}-  peek ptr = do-    px <- peek (castPtr ptr)-    Alpha px <$> peekByteOff ptr (sizeOf px)-  {-# INLINE peek #-}-  poke ptr (Alpha px a) = do-    poke (castPtr ptr) px-    pokeByteOff ptr (sizeOf px) a-  {-# INLINE poke #-}
src/Graphics/Color/Model/CMYK.hs view
@@ -26,7 +26,6 @@   ) where  import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import Graphics.Color.Model.RGB 
src/Graphics/Color/Model/HSI.hs view
@@ -30,7 +30,6 @@   ) where  import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import Graphics.Color.Model.RGB 
src/Graphics/Color/Model/HSL.hs view
@@ -31,7 +31,6 @@   ) where  import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.HSV (hc2rgb) import Graphics.Color.Model.Internal import Graphics.Color.Model.RGB
src/Graphics/Color/Model/HSV.hs view
@@ -31,7 +31,6 @@   ) where  import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import Graphics.Color.Model.RGB 
src/Graphics/Color/Model/Internal.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-}@@ -6,6 +5,7 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE UndecidableInstances #-} -- | -- Module      : Graphics.Color.Model.Internal -- Copyright   : (c) Alexey Kuleshevich 2018-2019@@ -15,11 +15,21 @@ -- Portability : non-portable -- module Graphics.Color.Model.Internal-  ( Color-  , ColorModel(..)+  ( ColorModel(..)   , module Graphics.Color.Algebra   , showsColorModel   , showsColorModelOpen+  -- * Alpha+  , Alpha+  , Opaque+  , addAlpha+  , getAlpha+  , setAlpha+  , dropAlpha+  , modifyAlpha+  , modifyOpaque+  , Color(..)+  -- * Helpers   , foldr3   , foldr4   , traverse3@@ -39,6 +49,7 @@ import Control.Monad (liftM) import Data.Default.Class (Default(..)) import Data.Foldable+import Data.Kind import Data.Typeable import qualified Data.Vector.Generic as V import qualified Data.Vector.Generic.Mutable as VM@@ -46,8 +57,8 @@ import qualified Data.Vector.Unboxed as VU import Foreign.Ptr import Foreign.Storable+import GHC.TypeLits import Graphics.Color.Algebra-import Data.Kind  -- | A Color family with a color space and a precision of elements. data family Color cs e :: Type@@ -62,6 +73,7 @@       , VS.Storable (Color cs e)       , Typeable cs       , Elevator e+      , Typeable (Opaque cs)       ) =>       ColorModel cs e where   type Components cs e :: Type@@ -276,3 +288,116 @@   poke (castPtr p) c0   poke3 (p `plusPtr` sizeOf (undefined :: e)) c1 c2 c3 {-# INLINE poke4 #-}+++-----------+-- Alpha --+-----------++++data Alpha cs++data instance Color (Alpha cs) e = Alpha+  { _opaque :: !(Color cs e)+  , _alpha :: !e+  }++-- | Get the alpha channel value for the pixel+--+-- @since 0.1.0+getAlpha :: Color (Alpha cs) e -> e+getAlpha = _alpha+{-# INLINE getAlpha #-}++-- | Get the opaque pixel value, while leaving alpha channel intact.+--+-- @since 0.1.0+dropAlpha :: Color (Alpha cs) e -> Color cs e+dropAlpha = _opaque+{-# INLINE dropAlpha #-}++-- | Add an alpha channel value to an opaque pixel+--+-- @since 0.1.0+addAlpha :: Color cs e -> e -> Color (Alpha cs) e+addAlpha = Alpha+{-# INLINE addAlpha #-}++-- | Change the alpha channel value for the pixel+--+-- @since 0.1.0+setAlpha :: Color (Alpha cs) e -> e -> Color (Alpha cs) e+setAlpha px a = px { _alpha = a }+{-# INLINE setAlpha #-}++-- | Change the alpha channel value for the pixel+--+-- @since 0.1.0+modifyAlpha :: (e -> e) -> Color (Alpha cs) e -> Color (Alpha cs) e+modifyAlpha f px = px { _alpha = f (_alpha px) }+{-# INLINE modifyAlpha #-}++-- | Change the opaque pixel value, while leaving alpha channel intact.+--+-- @since 0.1.0+modifyOpaque :: (Color cs e -> Color cs' e) -> Color (Alpha cs) e -> Color (Alpha cs') e+modifyOpaque fpx pxa = pxa { _opaque = fpx (_opaque pxa) }+{-# INLINE modifyOpaque #-}++instance (Eq (Color cs e), Eq e) => Eq (Color (Alpha cs) e) where+  (==) (Alpha px1 a1) (Alpha px2 a2) = px1 == px2 && a1 == a2+  {-# INLINE (==) #-}++instance (ColorModel cs e, cs ~ Opaque (Alpha cs)) =>+         Show (Color (Alpha cs) e) where+  showsPrec _ = showsColorModel++type family Opaque cs where+  Opaque (Alpha (Alpha cs)) = TypeError ('Text "Nested alpha channels are not allowed")+  Opaque (Alpha cs) = cs+  Opaque cs = cs++instance (ColorModel cs e, cs ~ Opaque (Alpha cs)) =>+         ColorModel (Alpha cs) e where+  type Components (Alpha cs) e = (Components cs e, e)+  toComponents (Alpha px a) = (toComponents px, a)+  {-# INLINE toComponents #-}+  fromComponents (pxc, a) = Alpha (fromComponents pxc) a+  {-# INLINE fromComponents #-}+  showsColorModelName _ = ("Alpha (" ++) . showsColorModelName (Proxy :: Proxy (Color cs e)) . (')':)+++instance Functor (Color cs) => Functor (Color (Alpha cs)) where+  fmap f (Alpha px a) = Alpha (fmap f px) (f a)+  {-# INLINE fmap #-}++instance Applicative (Color cs) => Applicative (Color (Alpha cs)) where+  pure e = Alpha (pure e) e+  {-# INLINE pure #-}+  (Alpha fpx fa) <*> (Alpha px a) = Alpha (fpx <*> px) (fa a)+  {-# INLINE (<*>) #-}++instance Foldable (Color cs) => Foldable (Color (Alpha cs)) where+  foldr f acc (Alpha px a) = foldr f (f a acc) px+  {-# INLINE foldr #-}+  foldr1 f (Alpha px a) = foldr f a px+  {-# INLINE foldr1 #-}++instance Traversable (Color cs) => Traversable (Color (Alpha cs)) where+  traverse f (Alpha px a) = Alpha <$> traverse f px <*> f a+  {-# INLINE traverse #-}++instance (Storable (Color cs e), Storable e) => Storable (Color (Alpha cs) e) where+  sizeOf _ = sizeOf (undefined :: Color cs e) + sizeOf (undefined :: e)+  {-# INLINE sizeOf #-}+  alignment _ = alignment (undefined :: e)+  {-# INLINE alignment #-}+  peek ptr = do+    px <- peek (castPtr ptr)+    Alpha px <$> peekByteOff ptr (sizeOf px)+  {-# INLINE peek #-}+  poke ptr (Alpha px a) = do+    poke (castPtr ptr) px+    pokeByteOff ptr (sizeOf px) a+  {-# INLINE poke #-}
src/Graphics/Color/Model/RGB.hs view
@@ -29,7 +29,6 @@  import Foreign.Storable import Graphics.Color.Algebra-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal  -- | The most common @RGB@ color model
src/Graphics/Color/Model/Y.hs view
@@ -27,7 +27,6 @@  import Data.Coerce import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import Graphics.Color.Model.RGB 
src/Graphics/Color/Model/YCbCr.hs view
@@ -29,7 +29,6 @@   ) where  import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import Graphics.Color.Model.RGB import Graphics.Color.Model.Y
src/Graphics/Color/Space.hs view
@@ -14,7 +14,6 @@   , module X   ) where -import Graphics.Color.Model.Alpha as X import Graphics.Color.Model.Internal as X import Graphics.Color.Space.Internal as X import Graphics.Color.Space.RGB.Internal as X
src/Graphics/Color/Space/CIE1976/LAB.hs view
@@ -26,7 +26,6 @@   ) where  import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import Graphics.Color.Space.Internal 
src/Graphics/Color/Space/Internal.hs view
@@ -55,7 +55,6 @@   ) where  import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import qualified Graphics.Color.Model.Y as CM import Graphics.Color.Algebra@@ -64,7 +63,7 @@ import GHC.TypeNats import Data.Kind -class (Illuminant i, ColorModel (BaseModel cs) e, ColorModel cs e, Typeable (Opaque cs)) =>+class (Illuminant i, ColorModel (BaseModel cs) e, ColorModel cs e) =>   ColorSpace cs (i :: k) e | cs -> i where    type BaseModel cs :: Type
src/Graphics/Color/Space/RGB/AdobeRGB.hs view
@@ -33,7 +33,6 @@   ) where  import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import qualified Graphics.Color.Model.RGB as CM import Graphics.Color.Space
src/Graphics/Color/Space/RGB/Alternative/CMYK.hs view
@@ -30,7 +30,6 @@ import Data.Proxy import Data.Typeable import Foreign.Storable-import Graphics.Color.Model.Alpha import qualified Graphics.Color.Model.CMYK as CM import Graphics.Color.Model.Internal import Graphics.Color.Space
src/Graphics/Color/Space/RGB/Alternative/HSI.hs view
@@ -32,7 +32,6 @@ import Data.Proxy import Data.Typeable import Foreign.Storable-import Graphics.Color.Model.Alpha import qualified Graphics.Color.Model.HSI as CM import Graphics.Color.Model.Internal import Graphics.Color.Space
src/Graphics/Color/Space/RGB/Alternative/HSL.hs view
@@ -32,7 +32,6 @@ import Data.Proxy import Data.Typeable import Foreign.Storable-import Graphics.Color.Model.Alpha import qualified Graphics.Color.Model.HSL as CM import Graphics.Color.Model.Internal import Graphics.Color.Space
src/Graphics/Color/Space/RGB/Alternative/HSV.hs view
@@ -31,7 +31,6 @@ import Data.Coerce import Data.Proxy import Foreign.Storable-import Graphics.Color.Model.Alpha import qualified Graphics.Color.Model.HSV as CM import Graphics.Color.Model.Internal import Graphics.Color.Space
src/Graphics/Color/Space/RGB/Alternative/YCbCr.hs view
@@ -34,7 +34,6 @@ import Data.Coerce import Data.Proxy import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import qualified Graphics.Color.Model.YCbCr as CM import Graphics.Color.Space
src/Graphics/Color/Space/RGB/Derived/AdobeRGB.hs view
@@ -26,7 +26,6 @@   ) where  import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import qualified Graphics.Color.Model.RGB as CM import Graphics.Color.Space
src/Graphics/Color/Space/RGB/Derived/SRGB.hs view
@@ -26,7 +26,6 @@   ) where  import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import qualified Graphics.Color.Model.RGB as CM import Graphics.Color.Space
src/Graphics/Color/Space/RGB/Internal.hs view
@@ -43,7 +43,6 @@  import Data.Coerce import Graphics.Color.Algebra-import Graphics.Color.Model.Alpha import qualified Graphics.Color.Model.RGB as CM import Graphics.Color.Space.Internal 
src/Graphics/Color/Space/RGB/Luma.hs view
@@ -1,10 +1,12 @@-{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeFamilies #-}@@ -19,6 +21,8 @@ module Graphics.Color.Space.RGB.Luma   ( -- * Luma     pattern Y'+  , pattern Y'A+  , pattern Luma   , Y'   , Luma(..)   , Weight(..)@@ -29,10 +33,9 @@  import Data.Coerce import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.RGB as CM import Graphics.Color.Model.Internal-import Graphics.Color.Model.Y+import Graphics.Color.Model.Y as CM import Graphics.Color.Space.RGB.Internal  -------------@@ -40,25 +43,47 @@ -------------  -- | [Luma](https://en.wikipedia.org/wiki/Luma_(video\)) of a non-linear gamma corrected--- RGB color space.+-- RGB color space. (Not to be confused with luminance `Y`) data Y'  -- | Constructor for Luma.-newtype instance Color Y' e = Y' e+newtype instance Color Y' e = Luma (CM.Color CM.Y e) --- | `Y'` color model+-- | Constructor for Luma `Y'`. (Not to be confused with luminance `Y`)+--+-- @since 0.1.0+pattern Y' :: e -> Color Y' e+pattern Y' y = Luma (CM.Y y)+{-# COMPLETE Y' #-}++-- | Constructor for `Y'` with alpha channel. (Not to be confused with luminance `Y`)+--+-- @since 0.1.4+pattern Y'A :: e -> e -> Color (Alpha Y') e+pattern Y'A y a = Alpha (Luma (CM.Y y)) a+{-# COMPLETE Y'A #-}++-- | `Y'` - luma of a color space deriving instance Eq e => Eq (Color Y' e)--- | `Y'` color model+-- | `Y'` - luma of a color space deriving instance Ord e => Ord (Color Y' e)--- | `Y'` color model+-- | `Y'` - luma of a color space+deriving instance Functor (Color Y')+-- | `Y'` - luma of a color space+deriving instance Applicative (Color Y')+-- | `Y'` - luma of a color space+deriving instance Foldable (Color Y')+-- | `Y'` - luma of a color space+deriving instance Traversable (Color Y')+-- | `Y'` - luma of a color space deriving instance Storable e => Storable (Color Y' e)  --- | `Y'` color model+-- | `Y'` - as a color model instance Elevator e => Show (Color Y' e) where   showsPrec _ = showsColorModel --- | `Y'` color model+-- | `Y'` - as a color model instance Elevator e => ColorModel Y' e where   type Components Y' e = e   toComponents (Y' y) = y@@ -66,30 +91,7 @@   fromComponents = Y'   {-# INLINE fromComponents #-} --- | `Y'` color model-instance Functor (Color Y') where-  fmap f (Y' y) = Y' (f y)-  {-# INLINE fmap #-} --- | `Y'` color model-instance Applicative (Color Y') where-  pure = Y'-  {-# INLINE pure #-}-  (Y' fy) <*> (Y' y) = Y' (fy y)-  {-# INLINE (<*>) #-}---- | `Y'` color model-instance Foldable (Color Y') where-  foldr f !z (Y' y) = f y z-  {-# INLINE foldr #-}---- | `Y'` color model-instance Traversable (Color Y') where-  traverse f (Y' y) = Y' <$> f y-  {-# INLINE traverse #-}--- ------------------ -- Luma Weights -- ------------------@@ -112,7 +114,9 @@   { unWeight :: e   } deriving (Eq, Show, Num, Fractional, Floating, Functor) -+-- | Get the weights of a non-linear RGB color space that can be used for converting to `Luma`+--+-- @since 0.1.4 rgbLumaWeights ::      forall cs e' e. (Luma cs, RealFloat e)   => Color cs e'@@ -124,6 +128,8 @@ {-# INLINE rgbLumaWeights #-}  -- | Convert a non-linear RGB pixel to a luma pixel+--+-- @since 0.1.0 rgbLuma ::      forall cs i e' e. (Luma cs, RedGreenBlue cs i, Elevator e', Elevator e, RealFloat e)   => Color cs e'
src/Graphics/Color/Space/RGB/SRGB.hs view
@@ -33,7 +33,6 @@   ) where  import Foreign.Storable-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import qualified Graphics.Color.Model.RGB as CM import Graphics.Color.Space.Internal
src/Graphics/Pixel.hs view
@@ -15,6 +15,7 @@       PixelCMYK, PixelYCbCr, PixelYA, PixelRGBA, PixelHSIA, PixelHSLA,       PixelHSVA, PixelCMYKA, PixelYCbCrA)   , liftPixel+  , pixelColor   -- * Elevation   , toPixel8   , toPixel16
src/Graphics/Pixel/ColorSpace.hs view
@@ -16,9 +16,10 @@ -- module Graphics.Pixel.ColorSpace   ( Pixel(Pixel, PixelY, PixelXYZ, PixelRGB, PixelHSI, PixelHSL, PixelHSV,-      PixelCMYK, PixelYCbCr, PixelYA, PixelXYZA, PixelRGBA, PixelHSIA, PixelHSLA,-      PixelHSVA, PixelCMYKA, PixelYCbCrA)+      PixelCMYK, PixelYCbCr, PixelY', PixelYA, PixelXYZA, PixelRGBA, PixelHSIA, PixelHSLA,+      PixelHSVA, PixelCMYKA, PixelYCbCrA, PixelY'A)   , liftPixel+  , pixelColor   -- * Conversion   -- ** Color space   , convertPixel@@ -37,22 +38,25 @@   , toPixel64   , toPixelF   , toPixelD-  -- * sRGB color space+  -- * RGB+  -- ** sRGB color space   , pattern PixelSRGB   , pattern PixelSRGBA   , SRGB   , D65-  -- * Adobe RGB color space+  -- ** Adobe RGB color space   , AdobeRGB+  -- ** Luma+  , rgbPixelLuma   -- * Re-export of color space   , module Graphics.Color.Space+  , module Graphics.Color.Space.RGB.Luma   , module Graphics.Color.Space.RGB.Alternative   , module Graphics.Color.Algebra.Binary   ) where  import Data.Coerce import Graphics.Color.Adaptation.VonKries-import Graphics.Color.Model.Alpha import Graphics.Color.Model.Internal import Graphics.Color.Algebra.Binary import qualified Graphics.Color.Model.RGB as CM@@ -60,6 +64,7 @@ import Graphics.Color.Space.RGB.AdobeRGB import Graphics.Color.Space.RGB.Alternative import Graphics.Color.Space.RGB.SRGB+import Graphics.Color.Space.RGB.Luma import Graphics.Pixel.Internal  -- | Convert a pixel from one color space to any other.@@ -168,7 +173,21 @@ pattern PixelYCbCr y cb cr = Pixel (ColorYCbCr y cb cr) {-# COMPLETE PixelYCbCr #-} +-- | Constructor for a pixel with Luma (not to be confused with luminance `Y`)+--+-- @since 0.1.4+pattern PixelY' :: e -> Pixel Y' e+pattern PixelY' y = Pixel (Y' y)+{-# COMPLETE PixelY' #-} +-- | Constructor for a pixel with Luma and Alpha channel (not to be confused with luminance `Y`)+--+-- @since 0.1.4+pattern PixelY'A :: e -> e -> Pixel (Alpha Y') e+pattern PixelY'A y a = Pixel (Alpha (Y' y) a)+{-# COMPLETE PixelY'A #-}++ -- | Constructor for a pixel in RGB color space with Alpha channel -- -- @since 0.1.0@@ -215,6 +234,15 @@ pattern PixelYCbCrA :: e -> e -> e -> e -> Pixel (Alpha (YCbCr cs)) e pattern PixelYCbCrA y cb cr a = Pixel (ColorYCbCrA y cb cr a) {-# COMPLETE PixelYCbCrA #-}++-- | Convert an RGB pixel to `Y'` if it has the weights specified with `Luma`.+--+-- @since 0.1.4+rgbPixelLuma ::+     forall cs i e' e. (Luma cs, RedGreenBlue cs i, Elevator e', Elevator e, RealFloat e)+  => Pixel cs e'+  -> Pixel Y' e+rgbPixelLuma = liftPixel rgbLuma  -- | Compute luminance of a pixel color --
src/Graphics/Pixel/Internal.hs view
@@ -40,6 +40,9 @@ -- @since 0.1.0 newtype Pixel cs e = Pixel   { pixelColor :: Color cs e+  -- ^ Get to the underlying `Color`+  --+  -- @since 0.1.4   }  deriving instance Eq (Color cs e) => Eq (Pixel cs e)