3

I am trying to map out some data in Diagrams. I am completely new to Diagrams, but I essentially want to have a rectangle, that grows when I put other diagrams atop of it. I have scoured the docs, but havn't found anything.

Does there exist such a shape, or a way to know how much to scaleY?

duplode
  • 33,731
  • 7
  • 79
  • 150
Chris Wohlert
  • 610
  • 3
  • 12

1 Answers1

3

If all you need is a rectangle surrounding some diagram(s), boundingRect might be enough. It could look like this (note the pad is entirely optional):

-- Arbitrary example, taken from the manual.
contents :: Diagram B
contents = c ||| hrule 1 ||| c
    where
    c = circle 1 <> vrule 2

-- Adding a bounding rectangle around it, with a little padding.
example :: Diagram B
example = contents <> bounds
    where
    bounds = boundingRect (contents # pad 1.1)
        # lc red
duplode
  • 33,731
  • 7
  • 79
  • 150
  • 1
    Yes. I don't need something that "grows", I just need something to figure out its own size, based on content. It feels like a strange loop, to put contents atop bounds, and then give contents to bounds as parameter. Nevertheless, i just replaced my `scaleY (length items * 2)` ish calculation and it works awesomely. Thank you. – Chris Wohlert Feb 28 '20 at 23:59