graphics_shapes/contains/
line.rs1use crate::circle::Circle;
2use crate::line::LineType;
3use crate::polygon::Polygon;
4use crate::prelude::{ContainsShape, Line, Rect, Triangle};
5
6impl ContainsShape for Line {
7 fn contains_rect(&self, rect: &Rect) -> bool {
8 match self.line_type() {
9 LineType::Point => {
10 self.start() == rect.top_left() && self.start() == rect.bottom_right()
11 }
12 LineType::Vertical | LineType::Horizontal => {
13 (self.start() == rect.top_left() && self.end() == rect.bottom_right())
14 || (self.end() == rect.top_left() && self.start() == rect.bottom_right())
15 }
16 LineType::Angled => false,
17 }
18 }
19
20 fn contains_circle(&self, _: &Circle) -> bool {
21 false
22 }
23
24 fn contains_line(&self, line: &Line) -> bool {
25 (self.start() == line.start() || self.start() == line.end())
26 && (self.end() == line.start() || self.end() == line.end())
27 }
28
29 fn contains_triangle(&self, _: &Triangle) -> bool {
30 false
31 }
32
33 fn contains_polygon(&self, _: &Polygon) -> bool {
38 false
39 }
40}