Skip to content

Commit 7c7021f

Browse files
committed
Release candidate 3; adjusted colours and a test
1 parent 465a56c commit 7c7021f

File tree

6 files changed

+23
-28
lines changed

6 files changed

+23
-28
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust_graph_visualiser"
3-
version = "1.9.2"
3+
version = "1.9.3"
44
edition = "2021"
55
authors = ["Sandra"]
66
repository = "https://github.com/an-Iceberg/rust_graph_visualiser"

src/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl DijkstraGraph
439439
self.add_line(13, 2, 1);
440440
self.add_line(15, 8, 10);
441441
self.add_line(14, 8, 14);
442-
self.add_line(1, 18, 10); // TODO: reduce length to 9
442+
self.add_line(1, 18, 9);
443443
self.add_line(17, 18, 3);
444444
self.add_line(16, 17, 2);
445445
self.add_line(7, 3, 1);

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ pub(crate) const BG_COLOR: u32 = 0x400080;
3535
pub(crate) const PATH_COLOR: u32 = 0x00ff00;
3636
pub(crate) const LINE_COLOR: u32 = 0x00c0c0;
3737
pub(crate) const POINT_COLOR: u32 = 0xff8000;
38-
pub(crate) const LINE_LENGTH_COLOR: u32 = 0xc09a9a;
39-
pub(crate) const UI_SPACE: f32 = 225.;
38+
pub(crate) const LINE_LENGTH_COLOR: u32 = 0xc09ac0;
39+
pub(crate) const UI_SPACING: f32 = 229.;
4040

4141
#[macroquad::main(window_configuration)]
4242
async fn main()

src/tests/graph_tests.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ fn shortest_path_large_b()
310310
let mut graph = DijkstraGraph::new();
311311
graph.insert_large_graph();
312312

313-
// TODO: add second valid path
314-
let should_path = vec![6, 4, 1, 2, 16, 17, 18];
313+
let should_path1 = vec![6, 4, 1, 2, 16, 17, 18];
314+
let should_path2 = vec![6, 4, 1, 18];
315315

316316
graph.set_start(6);
317317
graph.set_end(18);
@@ -323,9 +323,10 @@ fn shortest_path_large_b()
323323
Some(path) =>
324324
{
325325
path.iter()
326-
.zip(should_path.iter())
327-
.for_each(|(path_id, should_id)|
328-
{ assert_eq!(*path_id, *should_id); });
326+
.zip(should_path1.iter())
327+
.zip(should_path2.iter())
328+
.for_each(|((path_id, should_id1), should_id2)|
329+
{ assert!(*path_id == *should_id1 || *path_id == *should_id2); });
329330
},
330331
None => panic!("A path should have been found"),
331332
}

src/ui.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use crate::{graph::DijkstraGraph, Mode, VERSION, AUTHORS, UI_SPACE};
1+
use std::ops::Mul;
2+
3+
use crate::{graph::DijkstraGraph, Mode, VERSION, AUTHORS, UI_SPACING};
24

35
use egui_macroquad::{
46
egui::{epaint::Shadow, Align2, Rounding, Slider, Vec2, Visuals, Window, Color32, Stroke},
@@ -35,7 +37,7 @@ pub(crate) fn paint_ui(
3537
},
3638
window_fill: Color32::from_rgb(32, 0, 64),
3739
window_stroke: Stroke::new(2., Color32::from_rgb(0, 192, 192)),
38-
override_text_color: Some(Color32::from_rgb(216, 167, 215)),
40+
override_text_color: Some(Color32::from_rgb(255, 210, 255)),
3941
// widgets: Widgets::style(&self, response),
4042
..Default::default()
4143
});
@@ -114,11 +116,11 @@ pub(crate) fn paint_ui(
114116

115117
ui.add_space(match (&mode, selected_point_id)
116118
{
117-
(Mode::Move, _) => UI_SPACE,
118-
(Mode::Line, None) => UI_SPACE-33.,
119-
(Mode::Line, Some(_)) => UI_SPACE-75.,
120-
(Mode::Point, _) => UI_SPACE-14.,
121-
(Mode::Path, _) => UI_SPACE-58.
119+
(Mode::Move, _) => UI_SPACING,
120+
(Mode::Line, None) => UI_SPACING-33.,
121+
(Mode::Line, Some(_)) => UI_SPACING-75.,
122+
(Mode::Point, _) => UI_SPACING-14.,
123+
(Mode::Path, _) => UI_SPACING-58.
122124
});
123125

124126
ui.separator();
@@ -139,14 +141,10 @@ pub(crate) fn paint_ui(
139141
ui.separator();
140142
ui.heading("✨Style✨");
141143
ui.separator();
144+
ui.checkbox(hexagons, "Hexagons");
145+
ui.separator();
142146

143-
ui.horizontal(|ui|
144-
{
145-
// TODO: print angle as plain text
146-
ui.label("Angle:");
147-
ui.add_enabled_ui(false, |ui|
148-
{ ui.drag_angle(angle); });
149-
});
147+
ui.label(format!("Angle: {:.2}°", angle.mul(180./3.14159265)));
150148

151149
ui.horizontal(|ui|
152150
{
@@ -184,10 +182,6 @@ pub(crate) fn paint_ui(
184182
if ui.button("Reset").clicked() { *path_thickness = 2.0; }
185183
});
186184

187-
ui.separator();
188-
189-
ui.checkbox(hexagons, "Hexagons");
190-
191185
/*
192186
ui.separator();
193187

0 commit comments

Comments
 (0)