API ReferenceLayout Values
Transform
Affine transforms with composition, inversion, and hit mapping.
AffineTransform (re-exported as incular_core::Transform).
use incular::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let shift = AffineTransform::translation(Offset::new(8.0, 0.0));
let tilt = AffineTransform::rotation(0.1);
let combined = shift.then(tilt);
let app = Application::new(move |_cx| {
Container::builder()
.padding(EdgeInsets::all(24.0))
.alignment(Alignment::CENTER)
.child(
Container::new()
.transform(combined)
.color(Color::WHITE)
.padding(EdgeInsets::all(16.0))
.child(Text::new("Tilted")),
)
.build()
.into()
})?;
incular::run(app)?;
Ok(())
}| Constructor | Produces |
|---|---|
IDENTITY | No-op transform |
translation(offset) | Shift by offset |
scale(s) / scale_non_uniform(x, y) | Uniform / axis scaling |
rotation(radians) | Clockwise, y-down |
skew(x, y) | Shear factors |
| Combinator | Effect |
|---|---|
then(other) | Apply other first |
inverse() | Reversed transform or None |
transform_point / inverse_transform_point | Map points both ways |
transform_rect_bbox | Bounding box of a mapped rect |
Used by Container (transform) and
Transform.
Related: Offset.