Envelopes
srush opened this issue · 2 comments
srush commented
Notes on Envelopes from reading Pearl.
- Replace cached bounding box on Diagrams with Envelope class.
- Primitives can still return bounding boxes, ie for rect, spacer, etc. Diagram will wrap these in a function that returns distance to boundaries from origin.
- For paths of segments, we compute convex hull? Envelope computes distance to nearest half space.
- For circle it returns L2 * radius of vector?
- For arcs it is l2 is pointing in. -l2 if pointing out, and otherwise ...? (Distance to tangent at last angle?)
- For text, the envelope always returns 0
- Transformables are implemented for envelopes like Traces.
- For atop, simply max the resulting envelope (since origin is shared).
- For concat, we should special case it for efficiency. Take the max of all diagrams in one function to avoid n-calls.
- Envelope class might have some of the same properties as bounding box. Left, right, width, height. Although perhaps this is misleading if it is rotated.
Questions:
- Does additive pad make sense any longer? Diagrams uses multiplicative.
- Should we add directionally oriented atop? Is that useful?
- How do we envelope paths with arcs in them? Or just arcs?
- Should we allow using bounding boxes still? Might be more efficient in some cases.
danoneata commented
I'll just leave here some further pointers to the diagrams
library for future reference (they both have some useful notes in the comments):
srush commented
Gonna declare success here. Traces and envelopes seems strictly better and not really a speed issue at all. Neither required too much complexity.