1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::circle::Circle;
use crate::line::LineType;
use crate::polygon::Polygon;
use crate::prelude::{ContainsShape, Line, Rect, Triangle};

impl ContainsShape for Line {
    fn contains_rect(&self, rect: &Rect) -> bool {
        match self.line_type() {
            LineType::Point => {
                self.start() == rect.top_left() && self.start() == rect.bottom_right()
            }
            LineType::Vertical | LineType::Horizontal => {
                (self.start() == rect.top_left() && self.end() == rect.bottom_right())
                    || (self.end() == rect.top_left() && self.start() == rect.bottom_right())
            }
            LineType::Angled => false,
        }
    }

    fn contains_circle(&self, _: &Circle) -> bool {
        false
    }

    fn contains_line(&self, line: &Line) -> bool {
        (self.start() == line.start() || self.start() == line.end())
            && (self.end() == line.start() || self.end() == line.end())
    }

    fn contains_triangle(&self, _: &Triangle) -> bool {
        false
    }

    // fn contains_ellipse(&self, _: &Ellipse) -> bool {
    //     false
    // }

    fn contains_polygon(&self, _: &Polygon) -> bool {
        false
    }
}