Skip to content

Commit

Permalink
Add BackendBuild instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
cchalmers committed Dec 19, 2014
1 parent b64e765 commit b489484
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Diagrams/Backend/PGF.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}

{-# OPTIONS_GHC -fno-warn-orphans #-}

-----------------------------------------------------------------------------
-- |
Expand Down Expand Up @@ -73,6 +76,8 @@ import Diagrams.Backend.PGF.Surface
import Diagrams.Size
import Diagrams.Prelude hiding (r2, view)

import Diagrams.Backend.Build


type B = PGF

Expand All @@ -92,12 +97,12 @@ renderPGF outFile sizeSp surf = renderPGF' outFile opts
where
opts = case takeExtension outFile of
".pdf" -> def & surface .~ surf
& sizeSpec .~ sizeSp
& sizeSpec .~ sizeSp
& readable .~ False
& standalone .~ True

_ -> def & surface .~ surf
& sizeSpec .~ sizeSp
& sizeSpec .~ sizeSp

-- | Same as 'renderPGF' but takes 'Options PGF R2'.
renderPGF' :: (TypeableFloat n, Monoid' m) => FilePath -> Options PGF V2 n -> QDiagram PGF V2 n m -> IO ()
Expand Down Expand Up @@ -178,3 +183,10 @@ writeTexFile outFile opts d = do
hPutBuilder h $ renderDia PGF opts d
hClose h

------------------------------------------------------------------------
-- Instances
------------------------------------------------------------------------

instance BackendBuild PGF V2 Double where
outputSize = sizeSpec
saveDia outFile opts dia = renderPGF' outFile opts dia

0 comments on commit b489484

Please sign in to comment.