Layouts
refs #12
I was considering porting 2htdp/image for a while now, thanks for paving the way for a functional Purescript drawing lib!
WIP, not ready to merge yet.
Current state:
- remove
CompositeShape - remove positions from
Shapes - add
shapeSizeanddrawingSize(only covers the easy cases for now) - add
aboveandbesidefor laying outDrawings
TODO:
- more accurate drawing sizes (
Path;Outline,Text,Rotate,Clipped,WithShadow) - more layout options (
overlay,align, ...) - tests, examples
I'm considering normalising Paths at creation to have the leftmost and topmost points at x: 0.0 and y: 0.0 respectively.
Not sure how to handle Outlines. Canvas draws half of the outline inside, and half outside the shape. We could translate the shape and increase the size so that it is completely inside the bounds, or leave it as is.
Sorry about the mess in cleanup commit, removed spaces at ends of lines etc. Let me know if you see something offensive or of poor style.
Rebased on top of latest master.
Unfortunately there's a lot to do until this is complete, as per the above TODO.
Text size might work with Canvas.measureText, but getting a canvas drawing context is a problem here. Canvas just doesn't mesh well with the functional approach (no surprise there).
Maybe it would be easier with SVG or a custom layout engine (like 2htdp/image), but then again it would take some effort to port.
I'm using SVG for now. I'm interested in this project, but I don't see a clear path forward and the issue isn't very pressing. If anyone has suggestions regarding the size problems, I might revisit them.
Until then, you can try it out by specifying the fork as a dependency in bower.json, like
"purescript-drawing": "git://github.com/brainrape/purescript-drawing#d4a61f3b".