Closed robx closed 6 years ago
Another way to do this would be to use sizeAdjustment
on the bounding box of the diagram and the SizeSpec
, then apply the resulting transformation to the bounding box. But I'm not sure that is necessarily any simpler. Maybe there is some more elegant way to do it but honestly this seems fine and I don't want to go to the effort of really digging in enough to remember what it is.
I'm going to merge but open to changing the code later.
I noticed that PDF outputs of non-square diagrams ended up as square PDFs, with extra white space at the bottom, when specifying the output width only as a size spec. In contrast, for PNGs, the result is a PNG of the specified width with an appropriate height that preserves the aspect ratio of the diagram.
There's a test in this PR which draws a non-square diagram. It also shows some weird behaviour for PNGs, I didn't really understand that part (or how using
specToSize
could ever really do the right thing...). And then there's a rather heavy-handed fix for the PDF sizing issue that should probably not be merged like this. I couldn't figure out how to make the functions in Diagrams.Size do anything useful here.