module Graphics.PDF.Shading(
PDFShading(..)
, paintWithShading
, applyShading
) where
import Graphics.PDF.Draw
import Graphics.PDF.LowLevel.Types
import Control.Monad.State(gets)
import Graphics.PDF.Shapes(setAsClipPath)
import Control.Monad.Writer
import Graphics.PDF.LowLevel.Serializer
applyShading :: PDFShading -> Draw ()
applyShading shade = do
shadingMap <- gets shadings
(newName,newMap) <- setResource "Shading" shade shadingMap
modifyStrict $ \s -> s { shadings = newMap }
tell . mconcat $[ serialize "\n/"
, serialize newName
, serialize " sh"
]
paintWithShading :: PDFShading
-> Draw a
-> Draw ()
paintWithShading shade d = do
withNewContext $ do
_ <- d
setAsClipPath
applyShading shade