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
|
use diaphragm_core::{
core_shapes::StraightPath, types::ShapeContext, ComplexShape, DrawResult, Drawable,
SolverContext,
};
#[derive(Copy, Clone)]
pub enum BracketType {
Opening,
Closing,
}
#[derive(Clone)]
pub struct Bracket {
pub r#type: BracketType,
}
impl ComplexShape for Bracket {
fn draw(&self, context: &ShapeContext, solver: &mut dyn SolverContext) -> DrawResult {
let mut result = DrawResult::new();
let bounds = context.bounds();
let path = match self.r#type {
BracketType::Opening => StraightPath::new(vec![
bounds.top_right(solver),
bounds.top_left(solver),
bounds.bottom_left(solver),
bounds.bottom_right(solver),
]),
BracketType::Closing => StraightPath::new(vec![
bounds.top_left(solver),
bounds.top_right(solver),
bounds.bottom_right(solver),
bounds.bottom_left(solver),
]),
};
result.push(Drawable::new(path, context.clone()));
result
}
}
|