iced_graphics/geometry/
path.rs1pub mod arc;
3
4mod builder;
5
6#[doc(no_inline)]
7pub use arc::Arc;
8pub use builder::Builder;
9
10pub use lyon_path;
11
12use crate::core::border;
13use crate::core::{Point, Size};
14
15#[derive(Debug, Clone)]
19pub struct Path {
20 raw: lyon_path::Path,
21}
22
23impl Path {
24 pub fn new(f: impl FnOnce(&mut Builder)) -> Self {
28 let mut builder = Builder::new();
29
30 f(&mut builder);
32
33 builder.build()
34 }
35
36 pub fn line(from: Point, to: Point) -> Self {
39 Self::new(|p| {
40 p.move_to(from);
41 p.line_to(to);
42 })
43 }
44
45 pub fn rectangle(top_left: Point, size: Size) -> Self {
48 Self::new(|p| p.rectangle(top_left, size))
49 }
50
51 pub fn rounded_rectangle(top_left: Point, size: Size, radius: border::Radius) -> Self {
54 Self::new(|p| p.rounded_rectangle(top_left, size, radius))
55 }
56
57 pub fn circle(center: Point, radius: f32) -> Self {
60 Self::new(|p| {
61 p.circle(center, radius);
62 p.close();
63 })
64 }
65
66 #[inline]
68 pub fn raw(&self) -> &lyon_path::Path {
69 &self.raw
70 }
71
72 #[inline]
74 pub fn transform(&self, transform: &lyon_path::math::Transform) -> Path {
75 Path {
76 raw: self.raw.clone().transformed(transform),
77 }
78 }
79}