ferroui_base/media/
path_geometry_collections.rs1use crate::media::media_collection::media_collection_type;
2use crate::media::{MediaCollection, PathFigure, PathGeometry, PathSegment};
3use crate::utilities::FormatError;
4use crate::Ref;
5
6media_collection_type!(
7 PathFigures, Ref<PathFigure>
9);
10
11impl PathFigures {
12 pub fn new() -> Self {
14 Self(MediaCollection::new())
15 }
16
17 pub fn from_items(items: impl IntoIterator<Item = Ref<PathFigure>>) -> Self {
19 Self(MediaCollection::from_items(items))
20 }
21
22 pub fn parse(path_data: &str) -> Result<PathFigures, FormatError> {
24 let path_geometry = PathGeometry::parse(path_data)?;
25 Ok(path_geometry.figures().expect("a parsed path geometry has figures"))
26 }
27}
28
29media_collection_type!(
30 PathSegments, Ref<PathSegment>
32);
33
34impl PathSegments {
35 pub fn new() -> Self {
37 Self(MediaCollection::new())
38 }
39
40 pub fn from_items(items: impl IntoIterator<Item = Ref<PathSegment>>) -> Self {
42 Self(MediaCollection::from_items(items))
43 }
44
45 pub fn with_capacity(capacity: usize) -> Self {
47 let _ = capacity;
48 Self(MediaCollection::new())
49 }
50}