pub trait Scale<N>{
// Required methods
fn to_relative(&self, absolute: N) -> f64;
fn to_absolute(&self, relative: f64) -> N;
fn max(&self) -> N;
fn min(&self) -> N;
// Provided methods
fn to_clamped_relative(&self, absolute: N) -> f64 { ... }
fn to_clamped_absolute(&self, relative: f64) -> N { ... }
fn to_relative_delta(&self, absolute_delta: N, relative_pos: f64) -> f64 { ... }
fn to_absolute_delta(&self, relative_delta: f64, absolute_pos: N) -> N { ... }
}Expand description
A scale is a mapping of an arbitrary, not necessarily linear, continuous and monotonically increasing range of numbers to a relative value between 0.0 and 1.0. It’s useful for converting corresponding values between different coordinate spaces, for example for processing input from or rendering to a graphical user interface. A typical example would be calculating the position of a slider knob that controls a logarithmically scaled parameter.