# llimphi-widget-fitted-box Scales a subtree to the available slot. The analogue of Flutter's `FittedBox`: the caller passes the content's **natural size** and a **fit policy**, and the widget applies an affine `transform` to the subtree so it fits the real slot (measured through the compositor's `LayoutBuilder` seam). The subtree ends up **centred** and, except under `BoxFit::Fill`, **preserves its aspect ratio**. Why it does not come for free: `taffy` sizes containers, but the content (text, image, custom painter) does not scale with its container — it is only positioned inside it. `FittedBox` applies a VISUAL scale over the whole subtree, so a `paint_with` canvas or a large piece of text fits into a tiny cell without the caller re-measuring anything. The widget's parent has `clip(true)` so no pixel escapes the slot (it only matters when the content's aspect does NOT match the slot under `BoxFit::None`, and never with `Contain`/`Fill`). ## API ```ignore use llimphi_widget_fitted_box::{fitted_box, BoxFit}; // An 800×600 image that must fit any slot, preserving aspect // (shown whole, possibly with bands). fitted_box((800.0, 600.0), BoxFit::Contain, || my_image_view()) ``` ## Pure functions `compute_fit` returns `(sx, sy, dx, dy)` for a given `(slot, inner, fit)` and is testable without a runtime. Useful to validate the algorithm, and for cases where the caller already has its own transform to compose with. --- Part of **llimphi** — see [llimphi](../../README.md).