mirror of
https://github.com/codedownio/haskell-plot.git
synced 2025-04-24 06:26:05 +00:00
add writeFigureState
darcs-hash:20100921083718-af16d-a92cc83c30af4d33de7ce17ec404358b1da9976a.gz
This commit is contained in:
parent
20322189f9
commit
4969d56416
@ -23,6 +23,7 @@ module Graphics.Rendering.Plot.Render (
|
||||
-- ** Outputting to file
|
||||
, OutputType(..)
|
||||
, writeFigure
|
||||
, writeFigureState
|
||||
-- * Notes
|
||||
-- $notes
|
||||
) where
|
||||
@ -53,7 +54,7 @@ import qualified Graphics.Rendering.Pango as P
|
||||
|
||||
--import Control.Monad.Reader
|
||||
--import Control.Monad.State
|
||||
import Control.Monad.Trans
|
||||
--import Control.Monad.Trans
|
||||
|
||||
import Graphics.Rendering.Plot.Types
|
||||
import Graphics.Rendering.Plot.Defaults
|
||||
@ -131,6 +132,23 @@ writeSurface rw fn (w,h) f = rw fn (fromIntegral w) (fromIntegral h) (flip C.ren
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-- | output the 'FigureState'
|
||||
writeFigureState :: OutputType -- ^ output file type
|
||||
-> FilePath -- ^ file path
|
||||
-> (Int,Int) -- ^ (width,height)
|
||||
-> FigureState -- ^ a FigureState
|
||||
-> IO ()
|
||||
writeFigureState PNG fn wh f = withImageSurface wh (writeSurfaceToPNG fn (renderFigureState f wh))
|
||||
writeFigureState PS fn wh f = writeSurfaceFS C.withPSSurface fn wh f
|
||||
writeFigureState PDF fn wh f = writeSurfaceFS C.withPDFSurface fn wh f
|
||||
writeFigureState SVG fn wh f = writeSurfaceFS C.withSVGSurface fn wh f
|
||||
|
||||
writeSurfaceFS :: (FilePath -> Double -> Double -> (C.Surface -> IO ()) -> IO ())
|
||||
-> FilePath -> (Int,Int) -> FigureState -> IO ()
|
||||
writeSurfaceFS rw fn (w,h) f = rw fn (fromIntegral w) (fromIntegral h) (flip C.renderWith (renderFigureState f (w,h)))
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
renderFigure :: FigureData -> Render ()
|
||||
renderFigure (Figure p t s d) = do
|
||||
cairo $ do
|
||||
|
Loading…
x
Reference in New Issue
Block a user