aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 065f98a..f33fb55 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -47,6 +47,13 @@ Node leftmost_node(const NodeAllocator &allocator)
return node;
}
+constexpr word_t clamp_to_width(long double value, long double min,
+ long double max)
+{
+ // translate v in [min, max] -> v' in [0, WIDTH]
+ // [min, max] -> [0, max-min] -> [0, WIDTH]
+ return WIDTH / (max - min) * (value - min);
+}
int main(void)
{