#style #graphics #color #elements #resolver #define #style-context

graphics-style

The styles of all graphics elements

21 unstable releases (3 breaking)

0.3.0 Apr 24, 2022
0.2.11 Apr 24, 2022
0.2.10 Mar 27, 2022
0.1.5 Mar 26, 2022
0.0.2 Mar 25, 2022

#652 in Images

23 downloads per month
Used in graphics-3d

MPL-2.0 license

86KB
1.5K SLoC

Rust 1K SLoC // 0.0% comments Wolfram 276 SLoC // 0.1% comments

Graphics Style

The definition of all graphics style properties.

Theme Style

If you want to make a theme, just define a new StyleContext.

#[test]
fn test_theme() {
    let mut resolver = StyleResolver::default();
    let my_theme = StyleContext { point_size: Some(2.0), ..Default::default() };
    resolver.set_theme_style(my_theme);
}

Custom Style

If you want to extend style directives, you just need to implement GraphicsStyle.

use graphics_style::{GraphicsStyle, RGBA, StyleContext};
pub struct CustomLineStyle {
    pub width: f32,
    pub color: RGBA,
}

impl GraphicsStyle for CustomLineStyle {
    fn draw_style(&self, state: &mut StyleContext) {
        state.line_width = Some(self.width);
        state.line_color = Some(self.color);
    }
}

Preset Colors

RGBA

Dependencies

~16MB
~127K SLoC