1 | //! Graphics primitives |
2 | |
3 | pub mod arc; |
4 | pub mod circle; |
5 | mod common; |
6 | pub mod ellipse; |
7 | pub mod line; |
8 | pub mod polyline; |
9 | mod primitive_style; |
10 | pub mod rectangle; |
11 | pub mod rounded_rectangle; |
12 | pub mod sector; |
13 | mod styled; |
14 | pub mod triangle; |
15 | |
16 | #[doc (no_inline)] |
17 | pub use self::rectangle::Rectangle; |
18 | pub use self::{ |
19 | arc::Arc, |
20 | circle::Circle, |
21 | ellipse::Ellipse, |
22 | line::Line, |
23 | polyline::Polyline, |
24 | primitive_style::{PrimitiveStyle, PrimitiveStyleBuilder, StrokeAlignment}, |
25 | rounded_rectangle::{CornerRadii, CornerRadiiBuilder, RoundedRectangle}, |
26 | sector::Sector, |
27 | triangle::Triangle, |
28 | }; |
29 | use crate::geometry::{Dimensions, Point}; |
30 | pub use embedded_graphics_core::primitives::PointsIter; |
31 | pub use styled::{Styled, StyledDimensions, StyledDrawable}; |
32 | |
33 | /// Primitive trait |
34 | pub trait Primitive: Dimensions { |
35 | /// Converts this primitive into a `Styled`. |
36 | fn into_styled<S>(self, style: S) -> Styled<Self, S> |
37 | where |
38 | Self: Sized, |
39 | { |
40 | Styled::new(self, style) |
41 | } |
42 | } |
43 | |
44 | /// Trait to check if a point is inside a closed shape. |
45 | pub trait ContainsPoint { |
46 | /// Returns `true` if the given point is inside the shape. |
47 | fn contains(&self, point: Point) -> bool; |
48 | } |
49 | |
50 | /// Offset outline trait. |
51 | pub trait OffsetOutline { |
52 | /// Offsets the outline of the shape. |
53 | /// |
54 | /// The offset is applied perpendicular to each element of the outline. |
55 | /// Offset values greater than zero will expand the shape and values less |
56 | /// than zero will shrink the shape. |
57 | fn offset(&self, offset: i32) -> Self; |
58 | } |
59 | |