The clamp and segment maths a bar or gauge is built from, no SDK. More...
Go to the source code of this file.
Functions | |
| 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. | |
| int | segment_width (int total, int gap, int count) |
| The width of one cell when a strip is carved into evenly spaced segments. | |
| 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. | |
| int | segments_filled (int level, int segments) |
| How many cells of a gauge a percentage lights, rounding up so any charge lights one. | |
| 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. | |
The clamp and segment maths a bar or gauge is built from, no SDK.
A gauge, a battery glyph, and a graph all do the same handful of sums: pin a value into a range, carve a strip into even cells, and map a reading to a pixel. Those live here as plain integer functions so the drawing that uses them stays on the SDK side and the maths can be tested off the watch. Nothing here reaches for a GRect: a caller hands over the width or the height it read.