packages feed

diagrams-svg 0.3.4 → 0.3.5

raw patch · 3 files changed

+59/−11 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

diagrams-svg.cabal view
@@ -1,5 +1,5 @@ Name:                diagrams-svg-Version:             0.3.4+Version:             0.3.5 Synopsis:            SVG backend for diagrams drawing EDSL. Homepage:            http://projects.haskell.org/diagrams/ License:             BSD3
src/Diagrams/Backend/SVG/CmdLine.hs view
@@ -87,6 +87,19 @@   &= summary "Command-line diagram generation."   &= program prog +-- | This is the simplest way to render diagrams, and is intended to+--   be used like so:+--+-- > ... definitions ...+-- >+-- > main = defaultMain myDiagram+--+--   Compiling this file will result in an executable which takes+--   various command-line options for setting the size, output file,+--   and so on, and renders @myDiagram@ with the specified options.+--+--   Pass @--help@ to the generated executable to see all available+--   options. defaultMain :: Diagram SVG R2 -> IO () defaultMain d = do   prog <- getProgName@@ -113,6 +126,14 @@            BS.writeFile (output opts) (renderSvg build)        | otherwise -> putStrLn $ "Unknown file type: " ++ last ps ++-- | @multiMain@ is like 'defaultMain', except instead of a single+--   diagram it takes a list of diagrams paired with names as input.+--   The generated executable then takes an argument specifying the+--   name of the diagram that should be rendered.  This is a+--   convenient way to create an executable that can render many+--   different diagrams without modifying the source code in between+--   each one. multiMain :: [(String, Diagram SVG R2)] -> IO () multiMain ds = do   prog <- getProgName
src/Graphics/Rendering/SVG.hs view
@@ -7,11 +7,12 @@     ) where  -- from base-import Data.List (intersperse)+import Data.List (intersperse, intercalate)  -- from diagrams-lib import Diagrams.Prelude hiding (Render, Attribute, close, e, (<>)) import Diagrams.TwoD.Text+import Diagrams.TwoD.Path (getFillRule)  import Text.Blaze.Svg11 ((!), mkPath, m, cr, hr, vr, lr, z) import qualified Text.Blaze.Svg11 as S@@ -53,32 +54,46 @@   , renderLineWidth   , renderLineCap   , renderLineJoin+  , renderFillRule+  , renderDashing+  , renderOpacity   ]  renderLineColor :: Style v -> S.Attribute renderLineColor s =   (renderAttr A.stroke lineColorRgb) `mappend`   (renderAttr A.strokeOpacity lineColorOpacity)- where lineColor_       = getLineColor `fmap` getAttr s-       lineColorRgb     = colorToRgbString `fmap` lineColor_-       lineColorOpacity = colorToOpacity `fmap` lineColor_+ where lineColor_       = getLineColor <$> getAttr s+       lineColorRgb     = colorToRgbString <$> lineColor_+       lineColorOpacity = colorToOpacity <$> lineColor_  renderFillColor :: Style v -> S.Attribute renderFillColor s =   (renderAttr A.fill fillColorRgb) `mappend`   (renderAttr A.fillOpacity fillColorOpacity)- where fillColor_       = getFillColor `fmap` getAttr s-       fillColorRgb     = colorToRgbString `fmap` fillColor_-       fillColorOpacity = colorToOpacity `fmap` fillColor_+ where fillColor_       = getFillColor <$> getAttr s+       fillColorRgb     = colorToRgbString <$> fillColor_+       fillColorOpacity = colorToOpacity <$> fillColor_  +renderOpacity :: Style v -> S.Attribute+renderOpacity s = renderAttr A.opacity opacity_+ where opacity_ = getOpacity <$> getAttr s++renderFillRule :: Style v -> S.Attribute+renderFillRule s = renderAttr A.fillRule fillRule_+  where fillRule_ = (fillRuleToStr . getFillRule) <$> getAttr s+        fillRuleToStr :: FillRule -> String+        fillRuleToStr Winding = "nonzero"+        fillRuleToStr EvenOdd = "evenodd"+ renderLineWidth :: Style v -> S.Attribute renderLineWidth s = renderAttr A.strokeWidth lineWidth_- where lineWidth_ = getLineWidth `fmap` getAttr s+ where lineWidth_ = getLineWidth <$> getAttr s  renderLineCap :: Style v -> S.Attribute renderLineCap s = renderAttr A.strokeLinecap lineCap_-  where lineCap_ = (lineCapToStr . getLineCap) `fmap` getAttr s+  where lineCap_ = (lineCapToStr . getLineCap) <$> getAttr s         lineCapToStr :: LineCap -> String         lineCapToStr LineCapButt   = "butt"         lineCapToStr LineCapRound  = "round"@@ -86,11 +101,23 @@  renderLineJoin :: Style v -> S.Attribute renderLineJoin s = renderAttr A.strokeLinejoin lineJoin_-  where lineJoin_ = (lineJoinToStr . getLineJoin) `fmap` getAttr s+  where lineJoin_ = (lineJoinToStr . getLineJoin) <$> getAttr s         lineJoinToStr :: LineJoin -> String         lineJoinToStr LineJoinMiter = "miter"         lineJoinToStr LineJoinRound = "round"         lineJoinToStr LineJoinBevel = "bevel"++renderDashing :: Style v -> S.Attribute+renderDashing s = (renderAttr A.strokeDasharray arr) `mappend`+                  (renderAttr A.strokeDashoffset offset)+ where+  getDasharray  (Dashing a _) = a+  getDashoffset :: Dashing -> Double+  getDashoffset (Dashing _ o) = o+  dashArrayToStr              = intercalate "," . map show+  dashing_                    = getDashing <$> getAttr s+  arr                         = (dashArrayToStr . getDasharray) <$> dashing_+  offset                      = getDashoffset <$> dashing_  -- Render a style attribute if available, empty otherwise renderAttr :: S.ToValue s => (S.AttributeValue -> S.Attribute)