Skip to main content

folio_core/
point.rs

1//! Point and QuadPoint types.
2
3/// A 2D point.
4#[derive(Debug, Clone, Copy, PartialEq, Default)]
5pub struct Point {
6    pub x: f64,
7    pub y: f64,
8}
9
10impl Point {
11    pub fn new(x: f64, y: f64) -> Self {
12        Self { x, y }
13    }
14}
15
16/// A quadrilateral defined by four points.
17/// Used for text highlights and other non-rectangular regions.
18#[derive(Debug, Clone, Copy, PartialEq, Default)]
19pub struct QuadPoint {
20    pub p1: Point,
21    pub p2: Point,
22    pub p3: Point,
23    pub p4: Point,
24}
25
26impl QuadPoint {
27    pub fn new(p1: Point, p2: Point, p3: Point, p4: Point) -> Self {
28        Self { p1, p2, p3, p4 }
29    }
30}