summaryrefslogtreecommitdiff
path: root/src/vcr.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2025-08-10 11:37:52 -0700
committerVito Caputo <vcaputo@pengaru.com>2025-09-11 21:21:44 -0700
commit733fa3c2722a2c59d3e5a27b8becf19a86caf302 (patch)
tree14b49827ff7a70e38c3036c5211104f5b6b61d06 /src/vcr.c
parented683c9966edc3522aec958bdb40e8ff8a20287f (diff)
vcr: make vcr_draw_bar() base explicit parameter
Get rid of the overloaded meaning of negative values indicating base. While here also put the min_height logic in charts, the vcr side of this should be more dumb mechanism and less policy. While here these pixel space scaled heights should really get rounded to the nearest int in the scaled float->int conversion, otherwise 13.9 height becomes 13 when it should clearly be 14.
Diffstat (limited to 'src/vcr.c')
-rw-r--r--src/vcr.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/vcr.c b/src/vcr.c
index 20f726a..5406a9d 100644
--- a/src/vcr.c
+++ b/src/vcr.c
@@ -1195,35 +1195,32 @@ void vcr_mark_finish_line(vcr_t *vcr, vcr_layer_t layer, int row)
}
-/* draw a bar at the current phase into the specified layer of t % with a minimum of min_height pixels.
+/* draw a bar at the current phase into the specified layer of height pixels
*
* the only layers supported right now are grapha/graphb
*/
-void vcr_draw_bar(vcr_t *vcr, vcr_layer_t layer, int row, float t, int min_height)
+void vcr_draw_bar(vcr_t *vcr, vcr_layer_t layer, vcr_bar_base_t base, int row, int height)
{
- int height, y = row * VCR_ROW_HEIGHT;
+ int y = row * VCR_ROW_HEIGHT;
assert(vcr);
assert(vcr->backend);
assert(row >= 0);
assert(layer == VCR_LAYER_GRAPHA || layer == VCR_LAYER_GRAPHB);
- assert(min_height >= 0 && min_height < (VCR_ROW_HEIGHT - 1));
+ assert(height >= 0 && height < VCR_ROW_HEIGHT);
if ((row + 1) * VCR_ROW_HEIGHT >= vcr->height)
return;
- height = fabsf(t) * (float)(VCR_ROW_HEIGHT - 1);
-
- if (height < min_height)
- height = min_height;
-
- /* clamp the height to not potentially overflow */
- if (height > (VCR_ROW_HEIGHT - 1))
- height = (VCR_ROW_HEIGHT - 1);
-
- /* negative values project down from the top, positive up from bottom */
- if (t > 0.f)
+ switch (base) {
+ case VCR_BAR_BASE_BOTTOM:
y += VCR_ROW_HEIGHT - height - 1;
+ break;
+ case VCR_BAR_BASE_TOP:
+ break;
+ default:
+ assert(0);
+ }
switch (vcr->backend->type) {
#ifdef USE_XLIB
© All Rights Reserved