diff --git a/Color/src/Graphics/Color/Model.hs b/Color/src/Graphics/Color/Model.hs index 00a7d0b..1210429 100644 --- a/Color/src/Graphics/Color/Model.hs +++ b/Color/src/Graphics/Color/Model.hs @@ -8,6 +8,7 @@ -- module Graphics.Color.Model ( ColorModel(..) + , channelRgbColors -- * Alpha , Alpha , Opaque @@ -50,3 +51,13 @@ import Graphics.Color.Model.Internal import Graphics.Color.Model.RGB import Graphics.Color.Model.X import Graphics.Color.Model.YCbCr +import Data.Coerce +import Data.Proxy +import Data.List.NonEmpty + +-- | Uses `channelColors` to produce actual `RGB` colors for each +-- channel. Useful for plotting. +-- +-- @0.4.0 +channelRgbColors :: ColorModel cs e => Proxy (Color cs e) -> NonEmpty (Color RGB Word8) +channelRgbColors = coerce . channelColors diff --git a/Color/src/Graphics/Color/Space/Internal.hs b/Color/src/Graphics/Color/Space/Internal.hs index 7cc3500..e180267 100644 --- a/Color/src/Graphics/Color/Space/Internal.hs +++ b/Color/src/Graphics/Color/Space/Internal.hs @@ -106,10 +106,12 @@ class (Illuminant i, ColorModel (BaseModel cs) e, ColorModel cs e) => -- @since 0.1.0 luminance :: (Elevator a, RealFloat a) => Color cs e -> Color (Y i) a - -- | Drop chromatic information and get only the grayscale information from the - -- color. Without knowledge of the source color the produced value is inconsequential. + -- | Drop chromatic information and get only the grayscale information from + -- the color. Without knowledge of the source color the produced value is + -- inconsequential, becaus each class of color spaces has its own notion of + -- grayscale (luma, luminocity, in linear or non-linear form, etc.) -- - -- @since 0.3.1 + -- @since 0.4.0 grayscale :: Color cs e -> Color X e -- | Replace the grayscale information, leaving the chromatic portion of the coloer @@ -119,7 +121,7 @@ class (Illuminant i, ColorModel (BaseModel cs) e, ColorModel cs e) => -- -- > replaceGrayscale c y = applyGrayscale c (const y) -- - -- @since 0.3.1 + -- @since 0.4.0 replaceGrayscale :: Color cs e -> Color X e -> Color cs e replaceGrayscale c y = applyGrayscale c (const y) {-# INLINE replaceGrayscale #-} @@ -132,7 +134,7 @@ class (Illuminant i, ColorModel (BaseModel cs) e, ColorModel cs e) => -- -- > applyGrayscale c f = replaceGrayscale c (f (grayscale c)) -- - -- @since 0.3.1 + -- @since 0.4.0 applyGrayscale :: Color cs e -> (Color X e -> Color X e) -> Color cs e applyGrayscale c f = replaceGrayscale c (f (grayscale c)) {-# INLINE applyGrayscale #-}