embedded_graphics/primitives/
mod.rs

1//! Graphics primitives
2
3pub mod arc;
4pub mod circle;
5mod common;
6pub mod ellipse;
7pub mod line;
8pub mod polyline;
9mod primitive_style;
10pub mod rectangle;
11pub mod rounded_rectangle;
12pub mod sector;
13mod styled;
14pub mod triangle;
15
16#[doc(no_inline)]
17pub use self::rectangle::Rectangle;
18pub 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};
29use crate::geometry::{Dimensions, Point};
30pub use embedded_graphics_core::primitives::PointsIter;
31pub use styled::{Styled, StyledDimensions, StyledDrawable};
32
33/// Primitive trait
34pub 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.
45pub 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.
51pub 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}