AspectRatioFitter
Holds a width-to-height ratio for a portrait, a map or a video plate, keeping it correctly shaped in whatever box the layout hands it, cropped or letterboxed depending on mode, instead of stretching to fit. Goes under a Canvas.
On this page
Add it
+ Add node → Aspect Rect creates a node with it already on. Already have a node for it? Add component → AspectRatioFitter.
From a script
A script on the same node writes these fields by name. AspectRatioFitter is the name to pass.
rgs
set_number("AspectRatioFitter", "ratio", 1.7777778);
set_point("AspectRatioFitter", "anchor", vec2(0.5, 0.5)); Fields
| Field | Script name | Kind | Default | What it does |
|---|---|---|---|---|
| Ratio | ratio | number, at least 0.01 | 1.7778 | Width divided by height. |
| Mode | mode | one of FromWidth, FromHeight, Fit, Cover | Fit | Which axis gives way. |
| Anchor | anchor | two numbers (x, y), 0 to 1, step 0.01 | (0.5, 0.5) | The point of the original box that stays put, (0,0) top-left to (1,1) bottom-right. |