aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-07-27 01:25:27 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-07-27 01:25:27 +0100
commitfeabcf24a0509c5ec804b8b0a482f7025caa3182 (patch)
tree7bd349ca2eb6644c2243b59b6f2020323ac7eb66
parent1c06a4b61303bf18d4ff72ff959074e17e1dd25a (diff)
downloadcw_tree-feabcf24a0509c5ec804b8b0a482f7025caa3182.tar.gz
cw_tree-feabcf24a0509c5ec804b8b0a482f7025caa3182.tar.bz2
cw_tree-feabcf24a0509c5ec804b8b0a482f7025caa3182.zip
Draw the three iteration nodes in special colours
green for the centre, blue for the new nodes generated.
-rw-r--r--src/main.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 83dd289..475c899 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -52,6 +52,11 @@ struct State
long double lower, upper;
} bounds;
+ struct Iteration
+ {
+ Fraction left, centre, right;
+ } iteration;
+
State(const Fraction start) : allocator{256}
{
root = allocator.alloc(start);
@@ -63,7 +68,8 @@ struct State
void do_iteration(void)
{
- iterate(iteration_queue, allocator);
+ std::tie(iteration.left, iteration.centre, iteration.right) =
+ iterate(iteration_queue, allocator);
compute_bound_nodes();
compute_bounds();
}
@@ -116,6 +122,16 @@ struct State
stack.push(allocator.getVal(n.right.value()));
}
}
+
+ void draw_iteration_nodes()
+ {
+ word_t x_left = clamp_to_width(iteration.left.norm);
+ word_t x_centre = clamp_to_width(iteration.centre.norm);
+ word_t x_right = clamp_to_width(iteration.right.norm);
+ DrawLine(x_left, LINE_TOP, x_left, LINE_BOTTOM, BLUE);
+ DrawLine(x_right, LINE_TOP, x_right, LINE_BOTTOM, BLUE);
+ DrawLine(x_centre, LINE_TOP, x_centre, LINE_BOTTOM, GREEN);
+ }
};
int main(void)
@@ -152,6 +168,7 @@ int main(void)
DrawLine(0, HEIGHT / 2, WIDTH, HEIGHT / 2, WHITE);
state.draw_nodes();
state.draw_bounds();
+ state.draw_iteration_nodes();
DrawText(format_str.c_str(), WIDTH / 2 - format_str_width / 2,
LINE_TOP - HEIGHT / 4, FONT_SIZE * 2, WHITE);
EndDrawing();