ferroui_vello/
rectangle_geometry_impl.rs1use crate::geometry_impl::{impl_geometry_impl, register, FillPath, GeometryImpl, GeometryImplBase, VelloPath};
2use crate::vello_extensions::rect_path;
3use ferroui_base::media::FillRule;
4use ferroui_base::Rect;
5use std::sync::Arc;
6
7pub struct RectangleGeometryImpl {
9 base: GeometryImplBase,
10 bounds: Rect,
11 stroke_path: VelloPath,
12}
13
14impl RectangleGeometryImpl {
15 pub fn new(rect: Rect) -> Arc<Self> {
17 let path = VelloPath::new(rect_path(rect), FillRule::NonZero);
18
19 register(Self { base: GeometryImplBase::new(), bounds: rect, stroke_path: path })
20 }
21
22 fn geometry_bounds(&self) -> Rect {
23 self.bounds
24 }
25}
26
27impl GeometryImpl for RectangleGeometryImpl {
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 FillPath::SameAsStroke
38 }
39}
40
41impl_geometry_impl!(RectangleGeometryImpl);