diagrams / diagrams-lib

Diagrams standard library
https://diagrams.github.io/
Other
135 stars 63 forks source link

Juxtaposing padded lines not working as expected. #330

Open bacchanalia opened 5 years ago

bacchanalia commented 5 years ago

I expect there to be separation between the segments because of the padX, but there is not. padline

{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
module Main where
import Diagrams.Prelude
import Diagrams.Backend.Cairo.CmdLine

ex :: Diagram Cairo
ex = foldl1 (|||) $ map (padX 2) [l, r # lc red]
  where
    l = strokeP $ p2 (0, 0) ~~ p2 (1, 1)
    r = strokeP $ p2 (1, 1) ~~ p2 (2, 0)

dia :: Diagram Cairo
dia = (centerXY ex # pad 1.1)

main = mainWith (dia # bg white)
byorgey commented 5 years ago

What version of diagrams-lib are you using?

bacchanalia commented 5 years ago

I'm using HEAD.

byorgey commented 5 years ago

l seems to work fine. But something funky is going on with the envelope of r:

image

{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies     #-}

module Main where

import           Diagrams.Backend.Rasterific.CmdLine
import           Diagrams.Prelude

ex2 :: Diagram Rasterific
ex2 = hcat . map showEnvelope $ [r, padX 2 r]
  where
    r = strokeP $ p2 (1, 1) ~~ p2 (2, 0)

dia :: Diagram Rasterific
dia = (centerXY ex2 # pad 1.1)

main = mainWith (dia # bg white)
byorgey commented 5 years ago

@bacchanalia , incidentally, foldl1 (|||) should be equivalent to hcat.