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 state::{Path, TurtleState, DrawingState};
use {Color, Event};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Response {
TurtleState(TurtleState),
DrawingState(DrawingState),
Event(Option<Event>),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Query {
Request(Request),
Update(StateUpdate),
Drawing(DrawingCommand),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Request {
TurtleState,
DrawingState,
Event,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum StateUpdate {
TurtleState(TurtleState),
DrawingState(DrawingState),
TemporaryPath(Option<Path>),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum DrawingCommand {
/// When a path is finished being animated, it needs to be persisted in the renderer
/// so it can be redrawn every frame
StorePath(Path),
/// Begins filling with the current fill color from the next path onwards. If temporary_path is
/// set, it is included in the fill shape. Any paths sent via StorePath will be added to the
/// filled shape.
/// This command should be passed the fill color that was set at the time when this command
/// was issued. We cannot simply poll that from the state when this command is handled because
/// that may be well after the fill color has changed.
BeginFill(Color),
/// Send EndFill to finish the filled shape.
EndFill,
/// Clears the image completely
///
/// Panics if temporary_path is not None
Clear,
}