ferroui_vello/
simple_geometry_impl.rs1use crate::geometry_impl::{impl_geometry_impl, register, FillPath, GeometryImpl, GeometryImplBase, VelloPath};
2use ferroui_base::Rect;
3use std::sync::Arc;
4
5pub struct SimpleGeometryImpl {
7 base: GeometryImplBase,
8 bounds: Rect,
9 stroke_path: VelloPath,
10 fill: FillPath,
11}
12
13impl SimpleGeometryImpl {
14 pub fn new(stroke_path: VelloPath, fill: FillPath, bounds: Option<Rect>) -> Arc<Self> {
17 let bounds = bounds.unwrap_or_else(|| stroke_path.tight_bounds());
18
19 register(Self { base: GeometryImplBase::new(), bounds, stroke_path, fill })
20 }
21
22 fn geometry_bounds(&self) -> Rect {
23 self.bounds
24 }
25}
26
27impl GeometryImpl for SimpleGeometryImpl {
28 fn base(&self) -> &GeometryImplBase {
29 &self.base
30 }
31
32 fn stroke_path(&self) -> Option<VelloPath> {
33 Some(self.stroke_path.clone())
34 }
35
36 fn fill(&self) -> FillPath {
37 self.fill.clone()
38 }
39}
40
41impl_geometry_impl!(SimpleGeometryImpl);