recurve_svg/elements/
rectangle.rs1use bon::Builder;
2use simple_vector2::Vector2;
3use crate::to_xml::ToXml;
4use crate::xml::Element;
5
6#[derive(Builder, Debug, Clone)]
7pub struct Rectangle {
8 pub position: Vector2<f32>,
9 pub size: Vector2<f32>,
10 pub rounding: Option<Vector2<f32>>
11}
12
13impl ToXml for Rectangle {
14 fn to_xml(&self) -> Element {
15 Element::builder()
16 .name("rect")
17 .with_attribute(("x", self.position.x))
18 .with_attribute(("y", self.position.y))
19 .with_optional_attribute(self.rounding.map(|rounding| ("rx", rounding.x)))
20 .with_optional_attribute(self.rounding.map(|rounding| ("ry", rounding.y)))
21 .with_attribute(("width", self.size.x))
22 .with_attribute(("height", self.size.y))
23 .build()
24 }
25}