|
@@ -18,13 +18,15 @@ use super::{ObjectCore, Translate, ObjectModified};
|
|
|
pub struct Rectangle {
|
|
|
pub core: ObjectCore,
|
|
|
#[brw(magic(8u32))] // Number of following fields in struct
|
|
|
- pub corner_a: FieldOf<Coordinate>,
|
|
|
- pub corner_b: FieldOf<Coordinate>,
|
|
|
+ pub drawn_corner_a: FieldOf<Coordinate>,
|
|
|
+ pub drawn_corner_b: FieldOf<Coordinate>,
|
|
|
pub round_bottom_left: F64,
|
|
|
pub round_bottom_right: F64,
|
|
|
pub round_top_right: F64,
|
|
|
pub round_top_left: F64,
|
|
|
+ // origin_x = (corner_a.x + corner_b.x) / 2 * width_scale + origin_x_delta
|
|
|
pub modified: ObjectModified,
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// Custom Debug implementation to only print known fields
|
|
@@ -33,8 +35,8 @@ impl Debug for Rectangle {
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
f.debug_struct("Rectangle")
|
|
|
.field("core", &self.core)
|
|
|
- .field("corner_a", &self.corner_a)
|
|
|
- .field("corner_b", &self.corner_b)
|
|
|
+ .field("corner_a", &self.drawn_corner_a)
|
|
|
+ .field("corner_b", &self.drawn_corner_b)
|
|
|
.field("round_bottom_left", &self.round_bottom_left)
|
|
|
.field("round_bottom_right", &self.round_bottom_right)
|
|
|
.field("round_top_right", &self.round_top_right)
|
|
@@ -47,8 +49,8 @@ impl Default for Rectangle {
|
|
|
fn default() -> Self {
|
|
|
Self {
|
|
|
core: ObjectCore::default(ObjectType::Rectangle),
|
|
|
- corner_a: Coordinate { x: 0.0, y: 0.0 }.into(),
|
|
|
- corner_b: Coordinate { x: 0.0, y: 0.0 }.into(),
|
|
|
+ drawn_corner_a: Coordinate { x: 0.0, y: 0.0 }.into(),
|
|
|
+ drawn_corner_b: Coordinate { x: 0.0, y: 0.0 }.into(),
|
|
|
round_bottom_left: 0.0.into(),
|
|
|
round_bottom_right: 0.0.into(),
|
|
|
round_top_right: 0.0.into(),
|
|
@@ -62,16 +64,16 @@ impl Translate for Rectangle {
|
|
|
fn move_absolute(&mut self, origin: Option<Coordinate>, z: Option<f64>) {
|
|
|
origin.map(|origin| {
|
|
|
let delta: Coordinate = *self.core.origin - origin;
|
|
|
- *self.corner_a += delta;
|
|
|
- *self.corner_b += delta;
|
|
|
+ *self.drawn_corner_a += delta;
|
|
|
+ *self.drawn_corner_b += delta;
|
|
|
});
|
|
|
self.core.move_absolute(origin, z);
|
|
|
}
|
|
|
|
|
|
fn move_relative(&mut self, delta: Option<Coordinate>, z: Option<f64>) {
|
|
|
delta.map(|delta| {
|
|
|
- *self.corner_a += delta;
|
|
|
- *self.corner_b += delta;
|
|
|
+ *self.drawn_corner_a += delta;
|
|
|
+ *self.drawn_corner_b += delta;
|
|
|
});
|
|
|
self.core.move_relative(delta, z);
|
|
|
}
|