Skip to content

Commit 8235784

Browse files
committed
element/basic_shapes: add two Rectangle getters/setters
It is useful to be able to update rectangle styles after the rectangles were created, so we add a helper for it. It is also useful to be able to get the point coordinates.
1 parent 16714cf commit 8235784

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

plotters/src/element/basic_shapes.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,20 @@ impl<Coord> Rectangle<Coord> {
418418
self.margin = (t, b, l, r);
419419
self
420420
}
421+
422+
/// Get the points of the rectangle
423+
/// - returns the element points
424+
pub fn get_points(&self) -> (&Coord, &Coord) {
425+
(&self.points[0], &self.points[1])
426+
}
427+
428+
/// Set the style of the rectangle
429+
/// - `style`: The shape style
430+
/// - returns a mut reference to the rectangle
431+
pub fn set_style<S: Into<ShapeStyle>>(&mut self, style: S) -> &mut Self {
432+
self.style = style.into();
433+
self
434+
}
421435
}
422436

423437
impl<'a, Coord> PointCollection<'a, Coord> for &'a Rectangle<Coord> {

0 commit comments

Comments
 (0)