diff options
| author | Arne Dußin | 2020-11-27 19:58:54 +0100 |
|---|---|---|
| committer | Arne Dußin | 2020-11-27 19:58:54 +0100 |
| commit | 4d3ee44eb4892bd454a1289f7fed308f82ec6a3b (patch) | |
| tree | 9b0aedff19f6517b2250d0e15149a086cac0e34f | |
| parent | 99e935b63bb023cfd46c8f3d81074d3faf7ce592 (diff) | |
| download | graf_karto-4d3ee44eb4892bd454a1289f7fed308f82ec6a3b.tar.gz graf_karto-4d3ee44eb4892bd454a1289f7fed308f82ec6a3b.zip | |
Make walls join nicer in corners
| -rw-r--r-- | src/tool/wall_tool.rs | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/tool/wall_tool.rs b/src/tool/wall_tool.rs index 2cc5b5d..715a8b9 100644 --- a/src/tool/wall_tool.rs +++ b/src/tool/wall_tool.rs @@ -61,11 +61,11 @@ impl Tool for WallTool { fn draw(&self, map_data: &MapData, rld: &mut RaylibDrawHandle, transform: &Transform) { for &(pos1, pos2) in map_data.walls() { - let pos1: Vector2 = transform.point_m_to_px(pos1).into(); - let pos2: Vector2 = transform.point_m_to_px(pos2).into(); + let pos1_px = transform.point_m_to_px(pos1); + let pos2_px = transform.point_m_to_px(pos2); rld.draw_line_ex( - pos1, - pos2, + pos1_px, + pos2_px, transform.length_m_to_px(0.1), Color { r: 200, @@ -74,6 +74,32 @@ impl Tool for WallTool { a: 255, }, ); + + /* Find walls that end/start at the start or end of this wall and draw part of a circle + * to join these two walls more nicely. + */ + for &(other1, other2) in map_data.walls() { + // Ignore the line segment if it's the same wall + if pos1 == other1 && pos2 == other2 { + continue; + } + + // TODO: Only draw segments when introducing transparency. + for pos in [pos1, pos2].iter() { + if *pos == other1 || *pos == other2 { + rld.draw_circle_v( + transform.point_m_to_px(*pos), + transform.length_m_to_px(0.05), + Color { + r: 200, + g: 120, + b: 120, + a: 255, + }, + ); + } + } + } } if let Some((pos1, pos2)) = self.unfinished_wall { |
