Skip to content

Loading…

Circles are not drawn with Cairo & PDF #28

Open
mahrz opened this Issue · 1 comment

3 participants

@mahrz

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
diagrams member

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.

@bergey bergey added the numeric label
@bergey bergey referenced this issue in diagrams/diagrams-lib
Merged

New stuff #218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.