diff options
Diffstat (limited to 'src/tool/polygon_room_tool.rs')
| -rw-r--r-- | src/tool/polygon_room_tool.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/tool/polygon_room_tool.rs b/src/tool/polygon_room_tool.rs index 1b079d2..33daaf5 100644 --- a/src/tool/polygon_room_tool.rs +++ b/src/tool/polygon_room_tool.rs @@ -1,8 +1,10 @@ +//! Tool to create rooms in the shape of generic polygons. + use super::Tool; +use crate::colours::DEFAULT_COLOURS; use crate::map::Map; use crate::math::{self, Polygon, PolygonError, Vec2}; use crate::transform::Transform; -use crate::colours::DEFAULT_COLOURS; use raylib::core::drawing::{RaylibDraw, RaylibDrawHandle}; struct UnfinishedPolygon { @@ -10,6 +12,7 @@ struct UnfinishedPolygon { pub working_corner: Vec2<f64>, } +/// The tool itself. pub struct PolygonRoomTool { unfinished_polygon: Option<UnfinishedPolygon>, } @@ -76,6 +79,8 @@ impl UnfinishedPolygon { } impl PolygonRoomTool { + /// Create a new polygon room tool. There should be only one instance and it should be created + /// in the editor. pub fn new() -> Self { Self { unfinished_polygon: None, @@ -103,7 +108,7 @@ impl Tool for PolygonRoomTool { transform.point_m_to_px(&polygon.corners[0]), transform.point_m_to_px(&polygon.working_corner), transform.length_m_to_px(0.1) as f32, - DEFAULT_COLOURS.room_selected + DEFAULT_COLOURS.room_selected, ); } else if polygon.corners.len() == 2 { // We have three valid corners, so we can draw a triangle. @@ -111,7 +116,7 @@ impl Tool for PolygonRoomTool { transform.point_m_to_px(&polygon.corners[0]), transform.point_m_to_px(&polygon.corners[1]), transform.point_m_to_px(&polygon.working_corner), - DEFAULT_COLOURS.room_selected + DEFAULT_COLOURS.room_selected, ) } else { // A proper polygon can be drawn. @@ -126,7 +131,7 @@ impl Tool for PolygonRoomTool { transform.point_m_to_px(&triangle[0]), transform.point_m_to_px(&triangle[1]), transform.point_m_to_px(&triangle[2]), - DEFAULT_COLOURS.room_selected + DEFAULT_COLOURS.room_selected, ) } } else if polygon.check_validity_completed().is_ok() { @@ -138,7 +143,7 @@ impl Tool for PolygonRoomTool { transform.point_m_to_px(&triangle[0]), transform.point_m_to_px(&triangle[1]), transform.point_m_to_px(&triangle[2]), - DEFAULT_COLOURS.room_selected + DEFAULT_COLOURS.room_selected, ) } } |
