logo
Expand description

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

Structs

Represent the color of a point, default color is black

Represent the width of a circle, default width is 1.0

Represent the edge color of a disk, default is transparent

Represent the edge width of a disk, default width is 1.0

Represent the color of a disk, default color is black

Represent the color of a line, default color is black

Represent the with of a line, default width is 1.0

Represent the color of a point, default color is black

Represent the size of a point, default size is 1.0

Represent the available style of a point.

A color with red, green, blue, and alpha channel.

Get default style when not specified.

Resolve when style is not specific or missing.

Traits

Trait for drawing a shape with a style.