Skip to content

Commit

Permalink
Should fix issue 43 along with fill branch of lib
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyrosenbluth committed Nov 27, 2013
1 parent 7ffe01a commit 4c3179e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
11 changes: 3 additions & 8 deletions src/Diagrams/Backend/SVG.hs
Expand Up @@ -119,12 +119,12 @@ data SVG = SVG

type B = SVG

data SvgRenderState = SvgRenderState { _clipPathId :: Int, _ignoreFill :: Bool }
data SvgRenderState = SvgRenderState { _clipPathId :: Int }

makeLenses ''SvgRenderState

initialSvgRenderState :: SvgRenderState
initialSvgRenderState = SvgRenderState 0 False
initialSvgRenderState = SvgRenderState 0

-- | Monad to keep track of state when rendering an SVG.
-- Currently just keeps a monotonically increasing counter
Expand Down Expand Up @@ -164,11 +164,9 @@ renderRTree (Node (RPrim accTr p) _) = (render SVG (transform accTr p))
renderRTree (Node (RStyle sty) ts)
= R $ do
let R r = foldMap renderRTree ts
ignoreFill .= False
svg <- r
ign <- use ignoreFill
clippedSvg <- renderSvgWithClipping svg sty
return $ (S.g ! R.renderStyles ign sty) clippedSvg
return $ (S.g ! R.renderStyles sty) clippedSvg
renderRTree (Node (RFrozenTr tr) ts)
= R $ do
let R r = foldMap renderRTree ts
Expand Down Expand Up @@ -246,9 +244,6 @@ instance Renderable (Trail R2) SVG where

instance Renderable (Path R2) SVG where
render _ p = R $ do
-- Don't fill lines. diagrams-lib separates out lines and loops
-- for us, so if we see one line, they are all lines.
when (any (isLine . unLoc) . op Path $ p) $ (ignoreFill .= True)
return (R.renderPath p)

instance Renderable Text SVG where
Expand Down
8 changes: 3 additions & 5 deletions src/Graphics/Rendering/SVG.hs
Expand Up @@ -124,12 +124,10 @@ renderTransform t svg =
where (a1,a2,b1,b2,c1,c2) = getMatrix t
i = (a1,a2,b1,b2,c1,c2) == (1,0,0,1,0,0)

renderStyles :: Bool -> Style v -> S.Attribute
renderStyles ignoreFill s = mconcat . map ($ s) $
renderStyles :: Style v -> S.Attribute
renderStyles s = mconcat . map ($ s) $
[ renderLineColor
, if ignoreFill
then const (renderAttr A.fillOpacity (Just (0 :: Double)))
else renderFillColor
, renderFillColor
, renderLineWidth
, renderLineCap
, renderLineJoin
Expand Down

0 comments on commit 4c3179e

Please sign in to comment.