skia_safe/modules/svg/shape/
rect.rs1use crate::{
2 impl_default_make,
3 prelude::*,
4 svg::{DebugAttributes, Length, NodeSubtype},
5};
6use skia_bindings as sb;
7
8pub type Rect = RCHandle<sb::SkSVGRect>;
9
10impl NodeSubtype for sb::SkSVGRect {
11 type Base = sb::SkSVGShape;
12}
13
14impl_default_make!(Rect, sb::C_SkSVGRect_Make);
15
16impl DebugAttributes for Rect {
17 const NAME: &'static str = "Rect";
18
19 fn _dbg(&self, builder: &mut std::fmt::DebugStruct) {
20 self.as_base()._dbg(
21 builder
22 .field("x", &self.x())
23 .field("y", &self.y())
24 .field("width", &self.width())
25 .field("height", &self.height())
26 .field("rx", &self.rx())
27 .field("ry", &self.ry()),
28 );
29 }
30}
31
32impl Rect {
33 skia_svg_macros::attrs! {
34 SkSVGRect => {
35 x: Length [get(value) => Length::from_native_ref(value), set(value) => value.into_native()],
36 y: Length [get(value) => Length::from_native_ref(value), set(value) => value.into_native()],
37 width: Length [get(value) => Length::from_native_ref(value), set(value) => value.into_native()],
38 height: Length [get(value) => Length::from_native_ref(value), set(value) => value.into_native()],
39 rx?: Length [get(value) => value.map(Length::from_native_ref), set(value) => value.into_native()],
40 ry?: Length [get(value) => value.map(Length::from_native_ref), set(value) => value.into_native()]
41 }
42 }
43}