Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
use super::funejson::Value; ← the fune runtime: the JSON value the test vectors use; fune build keeps it only where a signature takes one
use super::charts_scale_linear_scale::{floats, interpolate, normalise, pair, round6}; ← linearScale, another function of this group · built into the same file, even by a slim install
/// The domain value at a position in the range: linear_scale read backwards.
/// Never clamped; a position past the end of the axis is a value past the end
/// of the data.
///
/// # Panics
/// Panics if the domain or range does not have exactly two values, or the
/// range's ends are equal.
pub fn invert_linear(domain: &[f64], range: &[f64], value: f64) -> f64 {
let (d0, d1) = pair(domain, "domain");
let (r0, r1) = pair(range, "range");
round6(interpolate(d0, d1, normalise(r0, r1, value, "range")))
}
pub fn fune_vector(args: &[Value]) -> Value {
Value::Float(invert_linear(&floats(&args[0]), &floats(&args[1]), args[2].as_f64()))
}