aboutsummaryrefslogtreecommitdiff
path: root/src/map/mappable.rs
diff options
context:
space:
mode:
authorArne Dußin2020-12-15 00:46:54 +0100
committerArne Dußin2020-12-15 22:51:46 +0100
commit9799d3c6a8f0c242668203a1c70d7b6cfed3e855 (patch)
tree9116acbc886f680f82309a42b4e6147e65c1433b /src/map/mappable.rs
parent3bc690803fb59493ea8180fd630d65b3e26642d0 (diff)
downloadgraf_karto-9799d3c6a8f0c242668203a1c70d7b6cfed3e855.tar.gz
graf_karto-9799d3c6a8f0c242668203a1c70d7b6cfed3e855.zip
Refactor to make interaction between tools easier
Diffstat (limited to 'src/map/mappable.rs')
-rw-r--r--src/map/mappable.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/map/mappable.rs b/src/map/mappable.rs
new file mode 100644
index 0000000..f75c990
--- /dev/null
+++ b/src/map/mappable.rs
@@ -0,0 +1,20 @@
+//! Something that's mappable can be placed on the map and drawn at a specific position. It has a
+//! dimension on the map and may be scaleable
+
+use crate::math::Rect;
+use crate::scaleable::Scaleable;
+use crate::transform::Transform;
+use raylib::drawing::RaylibDrawHandle;
+
+pub trait Mappable {
+ /// Draw this to `rld` with the transform. An item that cannot be drawn is not mappable, so
+ /// this must always be implemented.
+ fn draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform);
+
+ /// Get the rectangle that contains the mappable object in its entirety without excess.
+ fn bounding_rect(&self) -> Rect<f64>;
+
+ fn as_scaleable(&self) -> Option<&dyn Scaleable> {
+ None
+ }
+}