packages feed

Chart-cairo 1.1 → 1.9.4.1

raw patch · 2 files changed

Files

Chart-cairo.cabal view
@@ -1,27 +1,30 @@ Name: Chart-cairo-Version: 1.1+Version: 1.9.4.1 License: BSD3 License-file: LICENSE-Copyright: Tim Docker, 2006-2010+Copyright: Tim Docker, 2006-2014 Author: Tim Docker <tim@dockerz.net> Maintainer: Tim Docker <tim@dockerz.net> Homepage: https://github.com/timbod7/haskell-chart/wiki Synopsis: Cairo backend for Charts. Description: Cairo backend for Charts. Category: Graphics-Cabal-Version: >= 1.6+Cabal-Version: 1.18 Build-Type: Simple  library+  default-language: Haskell98   Build-depends: base >= 3 && < 5-               , old-locale-               , time, mtl, array-               , cairo >= 0.9.11+               , array >= 0.5 && < 0.6+               , old-locale >= 1.0.0 && < 1.1+               , time >= 1.12 && < 1.13+               , cairo >= 0.9.11 && < 0.14                , colour >= 2.2.1 && < 2.4-               , data-default-class < 0.1+               , data-default-class < 0.2                , operational >= 0.2.2 && < 0.3-               , lens >= 3.9 && < 3.11-               , Chart >= 1.1 && < 1.2+               , lens >= 3.9 && < 5.3+               , Chart >= 1.9 && < 1.10+               , mtl >= 2.0 && < 2.4    Exposed-modules:         Graphics.Rendering.Chart.Backend.Cairo
Graphics/Rendering/Chart/Backend/Cairo.hs view
@@ -8,6 +8,7 @@   , FileOptions(..)   , runBackend   , renderableToFile+  , toFile   , defaultEnv    , fo_size@@ -15,13 +16,6 @@    , cBackendToFile -  , renderableToPNGFile  -- deprecated-  , renderableToPDFFile  -- deprecated-  , renderableToPSFile   -- deprecated-  , renderableToSVGFile  -- deprecated-  -  , sparkLineToPDF       -- deprecated-  , sparkLineToPNG       -- deprecated   ) where  import Data.Default.Class@@ -34,6 +28,7 @@ import Control.Lens(makeLenses) import Control.Monad.Reader import Control.Monad.Operational+import Control.Monad  import qualified Graphics.Rendering.Cairo as C import qualified Graphics.Rendering.Cairo.Matrix as CM@@ -44,8 +39,8 @@ import Graphics.Rendering.Chart.Drawing import Graphics.Rendering.Chart.Geometry as G import Graphics.Rendering.Chart.Renderable-import Graphics.Rendering.Chart.Simple import Graphics.Rendering.Chart.SparkLine+import Graphics.Rendering.Chart.State(EC, execEC)  ----------------------------------------------------------------------- -- Rendering Backend Environment@@ -76,11 +71,11 @@  -- | Run this backends renderer. runBackend :: CEnv -- ^ Environment to start rendering with.-           -> ChartBackend a  -- ^ Chart render code.+           -> BackendProgram a  -- ^ Chart render code.            -> C.Render a      -- ^ Cairo render code. runBackend env m = runBackend' env (withDefaultStyle m) -runBackend' :: CEnv -> ChartBackend a -> C.Render a+runBackend' :: CEnv -> BackendProgram a -> C.Render a runBackend' env m = eval env (view m)   where     eval :: CEnv -> ProgramView ChartBackendInstr a -> C.Render a@@ -96,7 +91,7 @@     eval env (WithLineStyle ls p :>>= f) = cWithLineStyle env ls p >>= step env f     eval env (WithClipRegion r p :>>= f) = cWithClipRegion env r p >>= step env f -    step :: CEnv -> (v -> ChartBackend a) -> v -> C.Render a+    step :: CEnv -> (v -> BackendProgram a) -> v -> C.Render a     step env f =  \v -> runBackend' env (f v)      walkPath :: Path -> C.Render ()@@ -136,12 +131,12 @@   C.moveTo 0 0   C.showText text -cWithTransform :: CEnv -> Matrix -> ChartBackend a -> C.Render a+cWithTransform :: CEnv -> Matrix -> BackendProgram a -> C.Render a cWithTransform env m p = preserveCState0 $ do   C.transform (convertMatrix m)   runBackend' env p -cWithFontStyle :: CEnv -> FontStyle -> ChartBackend a -> C.Render a+cWithFontStyle :: CEnv -> FontStyle -> BackendProgram a -> C.Render a cWithFontStyle env font p = preserveCState0 $ do   C.selectFontFace (G._font_name font)                     (convertFontSlant $ G._font_slant font) @@ -149,11 +144,11 @@   C.setFontSize (G._font_size font)   runBackend' env{ceFontColor=G._font_color font} p -cWithFillStyle :: CEnv -> FillStyle -> ChartBackend a -> C.Render a+cWithFillStyle :: CEnv -> FillStyle -> BackendProgram a -> C.Render a cWithFillStyle env fs p = do-  runBackend' env{ceFillColor=G._fill_colour fs} p+  runBackend' env{ceFillColor=G._fill_color fs} p -cWithLineStyle :: CEnv -> LineStyle -> ChartBackend a -> C.Render a+cWithLineStyle :: CEnv -> LineStyle -> BackendProgram a -> C.Render a cWithLineStyle env ls p = preserveCState0 $ do   C.setLineWidth (G._line_width ls)   C.setLineCap (convertLineCap $ G._line_cap ls)@@ -161,7 +156,7 @@   C.setDash (G._line_dashes ls) 0   runBackend' env{cePathColor=G._line_color ls} p -cWithClipRegion :: CEnv -> Rect -> ChartBackend a -> C.Render a+cWithClipRegion :: CEnv -> Rect -> BackendProgram a -> C.Render a cWithClipRegion env r p = preserveCState0 $ do   setClipRegion r   runBackend' env p@@ -185,15 +180,21 @@  -- | Generate an image file for the given renderable, at the specified path. Size and -- format are set through the `FileOptions` parameter.-renderableToFile :: FileOptions -> Renderable a -> FilePath -> IO (PickFn a)-renderableToFile fo r path = cBackendToFile fo cr path+renderableToFile :: FileOptions -> FilePath -> Renderable a -> IO (PickFn a)+renderableToFile fo path r = cBackendToFile fo cr path   where     cr = render r (fromIntegral width, fromIntegral height)     (width,height) = _fo_size fo +-- | Generate an image file from from the state content of an EC+-- computation. The state may have any type that is an instance of+-- `ToRenderable`+toFile :: (Default r, ToRenderable r) => FileOptions -> FilePath -> EC r () -> IO ()+toFile fo path ec = void $ renderableToFile fo path (toRenderable (execEC ec))+ -- | Generate an image file for the given drawing instructions, at the specified path. Size and -- format are set through the `FileOptions` parameter.-cBackendToFile :: FileOptions -> ChartBackend a -> FilePath -> IO a+cBackendToFile :: FileOptions -> BackendProgram a -> FilePath -> IO a cBackendToFile fo cr path = do     case (_fo_format fo) of       PS -> write C.withPSSurface@@ -217,28 +218,6 @@      (width,height) = _fo_size fo -{-# DEPRECATED renderableToPNGFile "use renderableToFile" #-}-renderableToPNGFile :: Renderable a -> Int -> Int -> FilePath -> IO (PickFn a)-renderableToPNGFile r width height path = renderableToFile (FileOptions (width,height) PNG) r path---- | Output the given renderable to a PDF file of the specifed size---   (in points), to the specified file.-{-# DEPRECATED renderableToPDFFile "use renderableToFile" #-}-renderableToPDFFile :: Renderable a -> Int -> Int -> FilePath -> IO ()-renderableToPDFFile r width height path = void $ renderableToFile (FileOptions (width,height) PDF) r path---- | Output the given renderable to a postscript file of the specifed size---   (in points), to the specified file.-{-# DEPRECATED renderableToPSFile "use renderableToFile" #-}-renderableToPSFile  :: Renderable a -> Int -> Int -> FilePath -> IO ()-renderableToPSFile r width height path  = void $ renderableToFile (FileOptions (width,height) PS) r path---- | Output the given renderable to an SVG file of the specifed size---   (in points), to the specified file.-{-# DEPRECATED renderableToSVGFile "use renderableToFile" #-}-renderableToSVGFile :: Renderable a -> Int -> Int -> FilePath -> IO ()-renderableToSVGFile r width height path = void $ renderableToFile (FileOptions (width,height) SVG) r path- -- ----------------------------------------------------------------------- -- Type Conversions: Chart -> Cairo -- -----------------------------------------------------------------------@@ -318,38 +297,5 @@  cArcNegative :: Point -> Double -> Double -> Double -> C.Render () cArcNegative p r a1 a2 = C.arcNegative (p_x p) (p_y p) r a1 a2---- -------------------------------------------------------------------------- Simple Instances--- -------------------------------------------------------------------------instance PlotPDFType (IO a) where-    pld fn args = do-        renderableToPDFFile (layoutDddToRenderable $ uplot (reverse args)) 640 480 fn-        return undefined--instance PlotPSType (IO a) where-    pls fn args = do-        renderableToPSFile (layoutDddToRenderable $ uplot (reverse args)) 640 480 fn-        return undefined--instance PlotPNGType (IO a) where-    plp fn args = do-        renderableToPNGFile (layoutDddToRenderable $ uplot (reverse args)) 640 480 fn-        return undefined---- -------------------------------------------------------------------------- SparkLine Functions--- --------------------------------------------------------------------------- | Generate a PNG for the sparkline, using its natural size.-{-# DEPRECATED sparkLineToPNG "use renderableToFile" #-}-sparkLineToPNG :: FilePath -> SparkLine -> IO (PickFn ())-sparkLineToPNG fp sp = renderableToFile (FileOptions (sparkSize sp) PNG) (sparkLineToRenderable sp) fp---- | Generate a PDF for the sparkline, using its natural size.-{-# DEPRECATED sparkLineToPDF "use renderableToFile" #-}-sparkLineToPDF :: FilePath -> SparkLine -> IO ()-sparkLineToPDF fp sp = void $ renderableToFile (FileOptions (sparkSize sp) PDF) (sparkLineToRenderable sp) fp  $( makeLenses ''FileOptions )