diff options
Diffstat (limited to 'core/src/core_shapes.rs')
-rw-r--r-- | core/src/core_shapes.rs | 73 |
1 files changed, 59 insertions, 14 deletions
diff --git a/core/src/core_shapes.rs b/core/src/core_shapes.rs index 805d82e..d8017ab 100644 --- a/core/src/core_shapes.rs +++ b/core/src/core_shapes.rs | |||
@@ -1,8 +1,44 @@ | |||
1 | use super::complex_shapes::{ComplexShape, DrawResult}; | 1 | pub struct CoreDrawable { |
2 | use super::rendering::{Render, Renderer}; | 2 | pub(crate) shape: CoreShape, |
3 | use super::solving::{Constrainable, SolverContext, SolverModel}; | 3 | pub(crate) context: CoreShapeContext, |
4 | use super::types::*; | 4 | } |
5 | |||
6 | impl CoreDrawable { | ||
7 | pub fn new(shape: CoreShape, context: CoreShapeContext) -> Self { | ||
8 | Self { shape, context } | ||
9 | } | ||
10 | } | ||
11 | |||
12 | pub enum CoreShape { | ||
13 | Rectangle(Rectangle), | ||
14 | Text(Text), | ||
15 | // StraightPath(StraightPath), | ||
16 | } | ||
5 | 17 | ||
18 | impl From<Rectangle> for CoreShape { | ||
19 | fn from(rectangle: Rectangle) -> Self { | ||
20 | CoreShape::Rectangle(rectangle) | ||
21 | } | ||
22 | } | ||
23 | |||
24 | impl From<Text> for CoreShape { | ||
25 | fn from(text: Text) -> Self { | ||
26 | CoreShape::Text(text) | ||
27 | } | ||
28 | } | ||
29 | |||
30 | pub struct DefinedCoreDrawable { | ||
31 | pub(crate) shape: DefinedCoreShape, | ||
32 | pub(crate) context: DefinedCoreShapeContext, | ||
33 | } | ||
34 | |||
35 | pub enum DefinedCoreShape { | ||
36 | Rectangle(Rectangle), | ||
37 | Text(DefinedText), | ||
38 | // StraightPath(StraightPath), | ||
39 | } | ||
40 | |||
41 | /* | ||
6 | pub trait CoreShape { | 42 | pub trait CoreShape { |
7 | fn constrain( | 43 | fn constrain( |
8 | &self, | 44 | &self, |
@@ -23,19 +59,25 @@ impl<T: CoreShape + Clone + 'static> ComplexShape for T { | |||
23 | panic!("Tried to decompose core shape") | 59 | panic!("Tried to decompose core shape") |
24 | } | 60 | } |
25 | } | 61 | } |
62 | */ | ||
26 | 63 | ||
27 | // TODO: add default | 64 | // TODO: add default |
28 | #[derive(Copy, Clone, Debug, Default)] | 65 | #[derive(Copy, Clone, Debug, Default)] |
29 | pub struct Rectangle {} | 66 | pub struct Rectangle {} |
30 | 67 | ||
68 | /* | ||
31 | impl CoreShape for Rectangle { | 69 | impl CoreShape for Rectangle { |
32 | fn to_render(&self, _model: &dyn SolverModel) -> Option<Box<dyn Render>> { | 70 | fn to_render(&self, _model: &dyn SolverModel) -> Option<Box<dyn Render>> { |
33 | Some(Box::new(*self)) | 71 | Some(Box::new(*self)) |
34 | } | 72 | } |
35 | } | 73 | } |
74 | */ | ||
75 | |||
76 | use crate::types::{CoreShapeContext, DefinedCoreShapeContext}; | ||
36 | 77 | ||
37 | pub use super::text::{DefinedText, Text}; | 78 | pub use super::text::{DefinedText, Text}; |
38 | 79 | ||
80 | /* | ||
39 | impl CoreShape for Text { | 81 | impl CoreShape for Text { |
40 | fn constrain( | 82 | fn constrain( |
41 | &self, | 83 | &self, |
@@ -62,18 +104,20 @@ impl CoreShape for Text { | |||
62 | .map(|path| -> Box<dyn Render> { Box::new(path) }) | 104 | .map(|path| -> Box<dyn Render> { Box::new(path) }) |
63 | } | 105 | } |
64 | } | 106 | } |
107 | */ | ||
65 | 108 | ||
66 | #[derive(Clone, Debug, Default)] | 109 | // #[derive(Clone, Debug, Default)] |
67 | pub struct StraightPath { | 110 | // pub struct StraightPath { |
68 | pub(crate) points: Vec<Point2D>, | 111 | // pub(crate) points: Vec<Point2D>, |
69 | } | 112 | // } |
70 | 113 | // | |
71 | impl StraightPath { | 114 | // impl StraightPath { |
72 | pub fn new(points: Vec<Point2D>) -> Self { | 115 | // pub fn new(points: Vec<Point2D>) -> Self { |
73 | Self { points } | 116 | // Self { points } |
74 | } | 117 | // } |
75 | } | 118 | // } |
76 | 119 | ||
120 | /* | ||
77 | pub struct DefinedStraightPath { | 121 | pub struct DefinedStraightPath { |
78 | pub(crate) points: Vec<DefinedPoint2D>, | 122 | pub(crate) points: Vec<DefinedPoint2D>, |
79 | } | 123 | } |
@@ -84,3 +128,4 @@ impl CoreShape for StraightPath { | |||
84 | .map(|path| -> Box<dyn Render> { Box::new(path) }) | 128 | .map(|path| -> Box<dyn Render> { Box::new(path) }) |
85 | } | 129 | } |
86 | } | 130 | } |
131 | */ | ||