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
use crate::color::Color;
use crate::coord::Coord;
#[cfg(feature = "serde_derive")]
use serde::{Deserialize, Serialize};
pub mod circle;
pub mod convert_shape;
pub mod line;
pub mod math;
pub mod rect;
#[cfg_attr(feature = "serde_derive", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum DrawType {
Stroke(Color),
Fill(Color),
}
pub fn fill(color: Color) -> DrawType {
DrawType::Fill(color)
}
pub fn stroke(color: Color) -> DrawType {
DrawType::Stroke(color)
}
pub trait Shape {
fn draw_type(&self) -> DrawType;
fn with_draw_type(&self, draw_type: DrawType) -> Self;
fn translate_by<P: Into<Coord>>(&self, delta: P) -> Self;
fn move_to<P: Into<Coord>>(&self, xy: P) -> Self;
fn points(&self) -> Vec<Coord>;
}