haskellgraphicshaskell-diagrams

Margin of a Haskell diagrams SVG file


I am trying this diagrams example:

funs          = map (flip (^)) [2..6]
visualize f   = stroke' (with & vertexNames .~ [[0 .. 6 :: Int]] )
                    (regPoly 7 1)
                  # lw none
                  # showLabels
                  # fontSize (Local 0.6)
             <> star (StarFun f) (regPoly 7 1)
                  # stroke # lw thick # lc red
example       = center . hcat' (with & sep .~ 0.5) $ map visualize funs

And here is the result:

enter image description here

Everything appears as expected that some of the numbers (or more precisely, the center of these numbers) are place near the edges of the image, so in the end they look like having been cut off.

Is there a way to solve this?


Solution

  • The problem is text doesn't have an envelope so it's size isn't taken into account. You can solve your problem by using the frame function which adds a border to the envelope.

    example = frame 2 . center . hcat' (with & sep .~ 5) $ map visualize funs
    

    example