xdot/xdot_parse/
draw.rs
1mod attrs;
4
5pub use self::attrs::{FontCharacteristics, Rgba, Style};
6
7#[derive(Debug, Clone, PartialEq)]
9#[cfg_attr(
10 feature = "pyo3",
11 pyo3::pyclass(eq, get_all, set_all, module = "xdot_rs.draw")
12)]
13pub struct Pen {
14 pub color: Rgba,
15 pub fill_color: Rgba,
16 pub line_width: f32,
17 pub line_style: Style,
18 pub font_size: f32,
19 pub font_name: String,
20 pub font_characteristics: FontCharacteristics,
21}
22impl Default for Pen {
23 fn default() -> Self {
24 Pen {
25 color: Default::default(),
26 fill_color: Default::default(),
27 line_width: 1.0,
28 line_style: Default::default(),
29 font_size: 14.0,
30 font_name: "Times-Roman".to_owned(),
31 font_characteristics: Default::default(),
32 }
33 }
34}
35#[cfg(feature = "pyo3")]
36#[pyo3::pymethods]
37impl Pen {
38 #[new]
39 #[pyo3(signature = (
40 color=Default::default(),
41 fill_color=Default::default(),
42 line_width=1.0,
43 line_style=Default::default(),
44 font_size=14.0,
45 font_name="Times-Roman".to_owned(),
46 font_characteristics=Default::default(),
47 ))]
48 fn new(
49 color: Rgba,
50 fill_color: Rgba,
51 line_width: f32,
52 line_style: Style,
53 font_size: f32,
54 font_name: String,
55 font_characteristics: FontCharacteristics,
56 ) -> Self {
57 Pen {
58 color,
59 fill_color,
60 line_width,
61 line_style,
62 font_size,
63 font_name,
64 font_characteristics,
65 }
66 }
67}
68
69#[cfg(feature = "pyo3")]
70#[pyo3::pymodule]
71#[pyo3(name = "draw")]
72pub fn pymodule(m: &pyo3::Bound<'_, pyo3::types::PyModule>) -> pyo3::PyResult<()> {
73 use pyo3::prelude::*;
74
75 m.add_class::<FontCharacteristics>()?;
76 m.add_class::<Rgba>()?;
77 m.add_class::<Style>()?;
78 m.add_class::<Pen>()?;
79 Ok(())
80}