Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update for R2 generalization in -lib

  • Loading branch information...
commit e1d40765e8bb58bca79c4e7de52eaaed9511fbbd 1 parent e382d4b
Brent Yorgey authored
View
17 src/Diagrams/Backend/Cairo.hs
@@ -1,4 +1,5 @@
-{-# LANGUAGE TypeFamilies, CPP #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE TypeFamilies #-}
-----------------------------------------------------------------------------
-- |
@@ -37,7 +38,7 @@
--
-- > data family Options Cairo R2 = CairoOptions
-- > { cairoFileName :: String -- ^ The name of the file you want generated
--- > , cairoSizeSpec :: SizeSpec2D -- ^ The requested size of the output
+-- > , cairoSizeSpec :: SizeSpec2D Double -- ^ The requested size of the output
-- > , cairoOutputType :: OutputType -- ^ the output format and associated options
-- > , cairoBypassAdjust :: Bool -- ^ Should the 'adjustDia' step be bypassed during rendering?
-- > }
@@ -94,10 +95,10 @@ module Diagrams.Backend.Cairo
, Cairo(..)
) where
-import System.FilePath (takeExtension)
+import System.FilePath (takeExtension)
-import Diagrams.Backend.Cairo.Internal
-import Diagrams.Prelude
+import Diagrams.Backend.Cairo.Internal
+import Diagrams.Prelude
-- $CairoOptions
--
@@ -107,7 +108,7 @@ import Diagrams.Prelude
--
-- > data family Options Cairo R2 = CairoOptions
-- > { cairoFileName :: String -- ^ The name of the file you want generated
--- > , cairoSizeSpec :: SizeSpec2D -- ^ The requested size of the output
+-- > , cairoSizeSpec :: SizeSpec2D Double -- ^ The requested size of the output
-- > , cairoOutputType :: OutputType -- ^ the output format and associated options
-- > }
--
@@ -128,7 +129,7 @@ import Diagrams.Prelude
-- This function is provided as a convenience; if you need more
-- flexibility than it provides, you can call 'renderDia' directly,
-- as described above.
-renderCairo :: FilePath -> SizeSpec2D -> Diagram Cairo R2 -> IO ()
+renderCairo :: FilePath -> SizeSpec2D Double -> Diagram Cairo R2 -> IO ()
renderCairo outFile sizeSpec d
= fst (renderDia Cairo (CairoOptions outFile sizeSpec outTy False) d)
where
@@ -138,4 +139,4 @@ renderCairo outFile sizeSpec d
".ps" -> PS
".pdf" -> PDF
".svg" -> SVG
- _ -> PNG
+ _ -> PNG
View
10 src/Diagrams/Backend/Cairo/Internal.hs
@@ -111,9 +111,9 @@ instance Backend Cairo R2 where
type Result Cairo R2 = (IO (), C.Render ())
data Options Cairo R2 = CairoOptions
{ cairoFileName :: String -- ^ The name of the file you want generated
- , cairoSizeSpec :: SizeSpec2D -- ^ The requested size of the output
+ , cairoSizeSpec :: SizeSpec2D Double -- ^ The requested size of the output
, cairoOutputType :: OutputType -- ^ the output format and associated options
- , cairoBypassAdjust :: Bool -- ^ Should the 'adjustDia' step be bypassed during rendering?
+ , cairoBypassAdjust :: Bool -- ^ Should the 'adjustDia' step be bypassed during rendering?
}
deriving Show
@@ -228,7 +228,7 @@ setSource c s = C.setSourceRGBA r g b a'
-- | Multiply the current transformation matrix by the given 2D
-- transformation.
-cairoTransf :: T2 -> C.Render ()
+cairoTransf :: T2D -> C.Render ()
cairoTransf t = C.transform m
where m = CM.Matrix a1 a2 b1 b2 c1 c2
(unr2 -> (a1,a2)) = apply t unitX
@@ -276,7 +276,7 @@ instance Renderable (Path R2) Cairo where
-- Can only do PNG files at the moment...
-instance Renderable Image Cairo where
+instance Renderable (Image Double) Cairo where
render _ (Image file sz tr) = C . lift $ do
if ".png" `isSuffixOf` file
then do
@@ -303,7 +303,7 @@ instance Renderable Image Cairo where
]
-- see http://www.cairographics.org/tutorial/#L1understandingtext
-instance Renderable Text Cairo where
+instance Renderable (Text Double) Cairo where
render _ (Text tr al str) = C $ do
lift $ do
C.save
Please sign in to comment.
Something went wrong with that request. Please try again.