aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-07-26 20:40:16 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-07-26 20:46:34 +0100
commit3a911db3127165cfb0837457ebd9df1d421d86bc (patch)
tree85387279fb88f42a5a2a36c2465fafd552bd641d /src/main.cpp
parent99d37947496695b20c3a5db7464710a821b26a7a (diff)
downloadcw_tree-3a911db3127165cfb0837457ebd9df1d421d86bc.tar.gz
cw_tree-3a911db3127165cfb0837457ebd9df1d421d86bc.tar.bz2
cw_tree-3a911db3127165cfb0837457ebd9df1d421d86bc.zip
Helper to draw a fraction as text at point (x, y)
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f33fb55..aae5b72 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -55,6 +55,14 @@ constexpr word_t clamp_to_width(long double value, long double min,
return WIDTH / (max - min) * (value - min);
}
+void draw_fraction(Fraction f, word_t x, word_t y)
+{
+ std::string s{to_string(f)};
+ // Centered at (x, y)
+ int width = MeasureText(s.c_str(), FONT_SIZE);
+ DrawText(s.c_str(), x - width / 2, y - FONT_SIZE, FONT_SIZE, WHITE);
+}
+
int main(void)
{
// NodeAllocator allocator{256};