Twinside / Rasterific

A drawing engine in Haskell
BSD 3-Clause "New" or "Revised" License
140 stars 11 forks source link

Render with relative anchor #28

Open SwiftsNamesake opened 7 years ago

SwiftsNamesake commented 7 years ago

I wonder if it'd be possible to add some kind of withAnchor function. For example, if you want to render centred text at a point p, you would do withAnchor (V2 0.5 0.5) p $ ... or something similar. In other words, the coordinates are relative to the bounding box of the thing being rendered and are normalised with respect to it.

It would also be useful if you wanted to position elements relative to each other (eg. so that they're adjacent to each other).

I'm already aware of PlaneBoundable but there's no instance for text it seems. Also, withTransformation simply transforms the coordinates with the given matrix, right?

Maybe this functionality is already available (or easy to emulate), but if so I haven't found it.

Twinside commented 7 years ago

It should be doable while working with some bounding box, but it should appear "late" in the pipeline (once geometry is fully transformed). The thing is, by creating a withAnchor, I'm not sure it's possible to export it to pdf