geometry
2D geometry in f64: Point, Rect and the affine Matrix, in the layout of CSS and
SVG matrix(a b c d e f).
Enough to map between coordinate spaces: build and multiply transforms, invert one to bring a
point back, take the bounding box of a transformed rectangle (hit areas, gradient bounds), place
content in a container like CSS object-fit (fit), and simplify a polyline.
Install
Section titled “Install”Cargo feature geometry (enabled by default). To compile only this module:
or in Cargo.toml:
Import path: helpers4::geometry.
| Item | What it does |
|---|---|
FitAlign | Where fit places content in the space left over (or overflowing), as CSS object-position: 0.0 is left or top, 0.5 centered, 1.0 right or bottom. |
FitMode | How fit sizes content in a container, as CSS object-fit. |
fit | Places content in a container like CSS object-fit and object-position, e.g. |
Matrix | A 2D affine transformation (a 2×3 matrix), in the layout of CSS and SVG matrix(a, b, c, d, e, f): |
Point | A point in 2D space. |
Rect | An axis-aligned rectangle: its top-left corner and its size. |
simplify_polyline | Removes the points of a polyline that change its shape by less than tolerance, with the Ramer–Douglas–Peucker algorithm: each removed point is at most tolerance away from the simplified line. |
Size | A width and a height. |
