Loading...
Searching...
No Matches
scale.h
Go to the documentation of this file.
1
12#pragma once
13
18
27int clamp_int(int value, int lo, int hi);
28
41int segment_width(int total, int gap, int count);
42
51int fraction_px(int total, int num, int den);
52
63int segments_filled(int level, int segments);
64
79int plot_y(int y0, int height, int lo, int hi, int value);
80
int clamp_int(int value, int lo, int hi)
Pin a value into a range, so it lands on the nearer end when it falls outside.
Definition scale.c:9
int segments_filled(int level, int segments)
How many cells of a gauge a percentage lights, rounding up so any charge lights one.
Definition scale.c:40
int fraction_px(int total, int num, int den)
A fraction of a length in pixels, e.g. how far along a bar a moment sits.
Definition scale.c:31
int segment_width(int total, int gap, int count)
The width of one cell when a strip is carved into evenly spaced segments.
Definition scale.c:22
int plot_y(int y0, int height, int lo, int hi, int value)
Map a reading to its pixel row in a plot, with the low end at the bottom.
Definition scale.c:54