Skip to main content

graphitepdf_primitives/
geometry.rs

1#[derive(Clone, Copy, Debug, Default, PartialEq)]
2pub struct Point {
3    pub x: f32,
4    pub y: f32,
5}
6
7impl Point {
8    pub const fn new(x: f32, y: f32) -> Self {
9        Self { x, y }
10    }
11}
12
13#[derive(Clone, Copy, Debug, Default, PartialEq)]
14pub struct Size {
15    pub width: f32,
16    pub height: f32,
17}
18
19impl Size {
20    pub const fn new(width: f32, height: f32) -> Self {
21        Self { width, height }
22    }
23}
24
25#[derive(Clone, Copy, Debug, Default, PartialEq)]
26pub struct Bounds {
27    pub origin: Point,
28    pub size: Size,
29}
30
31impl Bounds {
32    pub const fn new(origin: Point, size: Size) -> Self {
33        Self { origin, size }
34    }
35
36    pub const fn from_origin_size(x: f32, y: f32, width: f32, height: f32) -> Self {
37        Self {
38            origin: Point::new(x, y),
39            size: Size::new(width, height),
40        }
41    }
42}