gfx/parallelogram.h
Parallelogram: a rectangle after an affine transform, as three corners.
#include <sonore/gfx/parallelogram.h>- 1type
- Guides: The native editor
On this page
Design notes
Why three corners and not a transform
They are the same information, and drawImageTransformed takes the transform. What the corners give is the other direction: a place stated as where the picture's corners LAND -- a label's backing plate skewed to sit on a drawn panel, a cover image mapped onto the face of a 3D box, the handles of a free-transform tool -- with the transform worked out from them (transformFrom) rather than composed by hand from a rotation, a shear and two scales nobody can read back. And a shape that a transform made is one that can be asked things a transform cannot answer directly: does it contain this point, how big is it, what rectangle bounds it.
The fourth corner is never stored: it is topRight + bottomLeft - topLeft, so a Parallelogram cannot be built that is not one.
Types 1
A rectangle after an affine transform, kept as three of its corners. The reference's Parallelogram, in float; the file comment says why corners and not a transform, and why the fourth is never stored.
A plain value with no invariants to keep: any three points are a valid parallelogram, and one whose corners lie on a line is empty and contains nothing (toRelative answers false for it).