Fusuma

Components / Components

scale_samples

values scaled to 0 to 255 between lo and hi (a value outside is held to the ends; hi <= lo is all zero), the first CHART_MAX of them.

values scaled to 0 to 255 between lo and hi (a value outside is held to the ends; hi <= lo is all zero), the first CHART_MAX of them.

For a chart of your own: the samples a line_chart draws.

Signature

pub fn scale_samples(values: &[i32], lo: i32, hi: i32) -> ([u8; CHART_MAX], usize)

Example

use fusuma::scale_samples;
let (scaled, n) = scale_samples(&[10, 20, 30], 10, 30);
assert_eq!(n, 3);
assert_eq!(scaled[..3], [0, 128, 255]);

All components · Source