module Diagrams.Backend.Postscript.CMYK (
CMYK(..)
, LineColorCMYK, getLineColorCMYK, mkLineColorCMYK, styleLineColorCMYK, lineColorCMYK, lineColorCMYKA, lcCMYK
, FillColorCMYK, getFillColorCMYK, mkFillColorCMYK, styleFillColorCMYK, recommendFillColorCMYK
, fillColorCMYK, fcCMYK
) where
import Control.Lens (Setter', sets, (.~))
import Data.Default.Class
import Data.Maybe (fromMaybe)
import Data.Monoid.Recommend
import Data.Semigroup
import Data.Typeable
import Diagrams.Core
import Graphics.Rendering.Postscript(CMYK(..))
newtype LineColorCMYK = LineColorCMYK (Last CMYK)
deriving (Typeable, Semigroup)
instance AttributeClass LineColorCMYK
instance Default LineColorCMYK where
def = LineColorCMYK (Last (CMYK 0 0 0 1))
getLineColorCMYK :: LineColorCMYK -> CMYK
getLineColorCMYK (LineColorCMYK (Last c)) = c
mkLineColorCMYK :: CMYK -> LineColorCMYK
mkLineColorCMYK = LineColorCMYK . Last
setAttr :: AttributeClass a => a -> Style v n -> Style v n
setAttr a = atAttr .~ Just a
styleLineColorCMYK :: Setter' (Style v Double ) CMYK
styleLineColorCMYK = sets modifyLineColorCMYK
where
modifyLineColorCMYK f s
= flip setAttr s
. mkLineColorCMYK
. f
. getLineColorCMYK
. fromMaybe def . getAttr
$ s
lineColorCMYK :: HasStyle a => CMYK -> a -> a
lineColorCMYK = applyAttr . mkLineColorCMYK
lineColorCMYKA :: HasStyle a => LineColorCMYK -> a -> a
lineColorCMYKA = applyAttr
lcCMYK :: HasStyle a => CMYK -> a -> a
lcCMYK = lineColorCMYK
newtype FillColorCMYK = FillColorCMYK (Recommend (Last CMYK))
deriving (Typeable, Semigroup)
instance AttributeClass FillColorCMYK
instance Default FillColorCMYK where
def = FillColorCMYK (Recommend (Last (CMYK 0 0 0 0)))
mkFillColorCMYK :: CMYK -> FillColorCMYK
mkFillColorCMYK = FillColorCMYK . Commit . Last
styleFillColorCMYK :: Setter' (Style v Double) CMYK
styleFillColorCMYK = sets modifyFillColorCMYK
where
modifyFillColorCMYK f s
= flip setAttr s
. mkFillColorCMYK
. f
. getFillColorCMYK
. fromMaybe def . getAttr
$ s
fillColorCMYK :: HasStyle a => CMYK -> a -> a
fillColorCMYK = applyAttr . mkFillColorCMYK
recommendFillColorCMYK :: HasStyle a => CMYK -> a -> a
recommendFillColorCMYK = applyAttr . FillColorCMYK . Recommend . Last
getFillColorCMYK :: FillColorCMYK -> CMYK
getFillColorCMYK (FillColorCMYK c) = getLast . getRecommend $ c
fcCMYK :: HasStyle a => CMYK -> a -> a
fcCMYK = fillColorCMYK