use super::colours::RGBA;
use super::Point;
use crate::{Border, Radius};
mod builder;
pub use builder::Builder;
#[derive(Debug, Clone, PartialEq)]
pub struct Shape {
points: Vec<Point>,
borders: Vec<Border>,
filled: (bool, Option<RGBA>),
radius: Radius,
}
impl Shape {
pub fn move_by(&mut self, position: Point) {
for point in &mut self.points {
*point = [position[0] + point[0], position[1] + point[1]];
}
}
pub fn points(&self) -> &Vec<Point> {
&self.points
}
pub fn position(&self) -> &Point {
&self.points[0]
}
pub fn borders(&self) -> Option<&Vec<Border>> {
if self.borders.is_empty() {
None
} else {
Some(&self.borders)
}
}
pub fn is_filled(&self) -> bool {
self.filled.0
}
pub fn fill_colour(&self) -> Option<RGBA> {
if !self.is_filled() {
None
} else {
self.filled.1
}
}
pub fn radius(&self) -> Radius {
self.radius
}
}