HPDF-1.0: Graphics/PDF/Shading.hs
---------------------------------------------------------
-- |
-- Copyright : (c) alpha 2007
-- License : BSD-style
--
-- Maintainer : misc@NOSPAMalpheccar.org
-- Stability : experimental
-- Portability : portable
--
-- PDF shading
---------------------------------------------------------
module Graphics.PDF.Shading(
-- * Shading
-- ** Type
PDFShading(..)
, paintWithShading
) where
import Graphics.PDF.Draw
import Graphics.PDF.LowLevel.Types
import Control.Monad.State(gets)
import Graphics.PDF.Shapes(setAsClipPath)
-- | Set alpha value for transparency
applyShading :: PDFShading -> Draw ()
applyShading shade = do
shadingMap <- gets shadings
(newName,newMap) <- setResource "Shading" shade shadingMap
modifyStrict $ \s -> s { shadings = newMap }
writeCmd ("\n/" ++ newName ++ " sh")
paintWithShading :: PDFShading -- ^ Shading
-> Draw a -- ^ Shape to paint
-> Draw ()
paintWithShading shade d = do
withNewContext $ do
d
setAsClipPath
applyShading shade