1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use super::raw_point::*;
use super::brush_properties::*;
use super::brush_definition::*;
use super::brush_drawing_style::*;
use canvas::*;
///
/// Represents a segment of a brush stroke
///
#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)]
pub struct BrushPoint {
/// Position of this segment
pub position: (f32, f32),
/// First control point for this segment
pub cp1: (f32, f32),
/// Second control point for this segment
pub cp2: (f32, f32),
/// Width of this segment
pub width: f32
}
///
/// Trait implemented by things that can draw brush strokes
///
pub trait Brush : Send+Sync {
///
/// Returns the brush points for rendering given a particular set of raw points
///
fn brush_points_for_raw_points(&self, raw_points: &[RawPoint]) -> Vec<BrushPoint>;
///
/// One or more brush strokes of this type are about to be rendered.
/// This brush should set up the graphics context appropriately.
///
fn prepare_to_render<'a>(&'a self, properties: &'a BrushProperties) -> Box<'a+Iterator<Item=Draw>>;
///
/// Renders a brush stroke to the specified graphics context
///
fn render_brush<'a>(&'a self, properties: &'a BrushProperties, points: &'a Vec<BrushPoint>) -> Box<'a+Iterator<Item=Draw>>;
///
/// Retrieves the definition for this brush
///
fn to_definition(&self) -> (BrushDefinition, BrushDrawingStyle);
}