Crates.io | graphics-style |
lib.rs | graphics-style |
version | 0.3.0 |
source | src |
created_at | 2022-03-25 10:16:14.901708 |
updated_at | 2022-04-24 12:47:25.855956 |
description | The styles of all graphics elements |
homepage | |
repository | https://github.com/oovm/graphics-rs |
max_upload_size | |
id | 556174 |
size | 86,122 |
The definition of all graphics style properties.
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);
}
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);
}
}