graphics_style/traits/
mod.rs

1use crate::*;
2mod convert;
3#[cfg(feature = "wolfram-expr")]
4mod wolfram;
5use std::fmt::{Debug, Formatter};
6
7/// Trait for drawing a shape with a style.
8#[allow(unused_variables)]
9pub trait GraphicsStyle {
10    /// Draws a shape with a style.
11    fn skip(&self) -> bool {
12        false
13    }
14    /// Draws a shape with a style.
15    ///
16    /// # Arguments
17    ///
18    /// * `state`:
19    ///
20    /// returns: ()
21    ///
22    /// # Examples
23    ///
24    /// ```rust
25    /// use graphics_style::{Color, GraphicsStyle3D, StyleContext};
26    /// pub struct CustomLineStyle {
27    ///     pub width: f32,
28    ///     pub color: Color,
29    /// }
30    ///
31    /// impl GraphicsStyle3D for CustomLineStyle {
32    ///     fn change_style(&self, state: &mut StyleContext) {
33    ///         state.line_width = Some(self.width);
34    ///         state.line_color = Some(self.color);
35    ///     }
36    /// }
37    /// ```
38    fn change_style(&self, state: &mut StyleContext);
39}
40
41impl Debug for dyn GraphicsStyle {
42    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
43        write!(f, "GraphicsStyle")
44    }
45}