Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circles are not drawn with Cairo & PDF #28

Open
mahrz24 opened this issue Jan 8, 2013 · 1 comment
Open

Circles are not drawn with Cairo & PDF #28

mahrz24 opened this issue Jan 8, 2013 · 1 comment
Labels

Comments

@mahrz24
Copy link

mahrz24 commented Jan 8, 2013

ghc 7.6.1, diagrams-*-0.6, cairo-0.12.4, cairo lib 1.12.8 the following code generates a blank PDF on Arch Linux (only for PDF output, PS or PNG works perfectly and draws a quarter circle in the upper left corner)

import Diagrams.Prelude
import Diagrams.Backend.Cairo
import Diagrams.Backend.Cairo.Internal

p :: Picture
p = circle 100 # fc black

renderTest =
fst $ renderDia Cairo (CairoOptions "test.pdf" (Width 550) PDF True) p

@byorgey
Copy link
Member

byorgey commented Mar 4, 2013

Here's another test case that exhibits the bug (presumably the same bug?):

{-# LANGUAGE NoMonomorphismRestriction #-}

import           Diagrams.Backend.Cairo.CmdLine
import           Diagrams.Prelude

import           Data.Tree
import           Diagrams.TwoD.Layout.Tree

enumTreesU :: Int -> [BTree ()]
enumTreesU 0 = [Empty]
enumTreesU n = [ BNode () l r
               | k <- [0..n-1]
               , l <- enumTreesU (n-1-k)
               , r <- enumTreesU k
               ]

drawBinTree :: BTree a -> Diagram Cairo R2
drawBinTree = drawRTree . symmLayout . b2r
  where
    b2r Empty         = Node Nothing []
    b2r (BNode a l r) = Node (Just a) (map b2r [l,r])
    drawRTree = renderTree' drawNode drawEdge
    drawNode Nothing  = mempty
    drawNode (Just _) = circle 0.3 # fc black
    drawEdge _ (Nothing,_)   = mempty
    drawEdge (_,pt1) (_,pt2) = pt1 ~~ pt2

dia = hcat' with { sep = 1 } . map drawBinTree . enumTreesU $ 5

main = defaultMain dia

Changing the 5 to 4 results in a properly rendered diagram. I've had trouble before with diagrams involving large numbers of circles.

ghc 7.6.1, cairo-0.12.4, cairo library 1.12.14.

This bug is so annoying, and so weird. Anyone who tracks it down will have my undying gratitude.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants