Skip to main content

transform_rect

Function transform_rect 

Source
pub fn transform_rect(m: Affine, r: Rect) -> Rect
Expand description

Maps all four corners and returns their bounding box.

use pdfrum_doc::geom;

use kurbo::Affine;

// A quarter turn maps the corners; the answer is their bounding box.
let turned = geom::transform_rect(Affine::rotate(std::f64::consts::FRAC_PI_2),
    geom::rect(0.0, 0.0, 10.0, 20.0));
assert!((geom::width(turned) - 20.0).abs() < 1e-4);
assert!((geom::height(turned) - 10.0).abs() < 1e-4);