svg_composer/element/
circle.rs1use crate::element::attributes::{Attributes, Size, ToSize};
2use crate::element::Element;
3
4#[derive(Clone)]
5pub struct Circle {
6 attributes: Attributes,
7}
8
9impl Circle {
10 pub fn new() -> Self {
11 Circle {
12 attributes: Attributes::default(),
13 }
14 }
15 pub fn set_pos<I>(mut self, pos: (I, I)) -> Self
16 where
17 I: ToSize,
18 {
19 self.attributes.cx = Some(pos.0.to_size());
20 self.attributes.cy = Some(pos.1.to_size());
21 self
22 }
23 pub fn set_radius<I>(mut self, radius: I) -> Self
24 where
25 I: ToSize,
26 {
27 self.attributes.radius = Some(radius.to_size());
28 self
29 }
30}
31
32impl Element for Circle {
33 fn get_mut_attributes(&mut self) -> &mut Attributes {
34 &mut self.attributes
35 }
36
37 fn get_attributes(&self) -> &Attributes {
38 &self.attributes
39 }
40
41 fn tag_name(&self) -> String {
42 "circle".to_string()
43 }
44}