lightweight_pdf_layout/
geometry.rs1#[derive(Clone, Copy, Debug)]
2pub struct Constraints {
3 pub max_width: f32,
4 pub max_height: f32,
5}
6
7#[derive(Clone, Copy, Debug, Default)]
8pub struct Size {
9 pub width: f32,
10 pub height: f32,
11}
12
13#[derive(Clone, Copy, Debug)]
18pub struct Rect {
19 pub x: f32,
20 pub y: f32,
21 pub width: f32,
22 pub height: f32,
23}
24
25impl Rect {
26 pub fn shrink(&self, amount: f32) -> Rect {
27 Rect {
28 x: self.x + amount,
29 y: self.y + amount,
30 width: (self.width - 2.0 * amount).max(0.0),
31 height: (self.height - 2.0 * amount).max(0.0),
32 }
33 }
34}