Scale

Trait Scale 

Source
pub trait Scale<N>
where N: Sub<Output = N> + Add<Output = N> + PartialOrd + FromFloat<f64> + ToFloat<f64> + Clone,
{ // 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.

Required Methods§

Source

fn to_relative(&self, absolute: N) -> f64

Source

fn to_absolute(&self, relative: f64) -> N

Source

fn max(&self) -> N

Source

fn min(&self) -> N

Provided Methods§

Source

fn to_clamped_relative(&self, absolute: N) -> f64

Source

fn to_clamped_absolute(&self, relative: f64) -> N

Source

fn to_relative_delta(&self, absolute_delta: N, relative_pos: f64) -> f64

Source

fn to_absolute_delta(&self, relative_delta: f64, absolute_pos: N) -> N

Implementations on Foreign Types§

Source§

impl<N, SN> Scale<N> for &SN
where N: Sub<Output = N> + Add<Output = N> + PartialOrd + FromFloat<f64> + ToFloat<f64> + Clone, SN: Scale<N>,

Source§

fn to_relative(&self, absolute: N) -> f64

Source§

fn to_absolute(&self, relative: f64) -> N

Source§

fn max(&self) -> N

Source§

fn min(&self) -> N

Source§

impl<N, SN> Scale<N> for Box<SN>
where N: Sub<Output = N> + Add<Output = N> + PartialOrd + FromFloat<f64> + ToFloat<f64> + Clone, SN: Scale<N>,

Source§

fn to_relative(&self, absolute: N) -> f64

Source§

fn to_absolute(&self, relative: f64) -> N

Source§

fn max(&self) -> N

Source§

fn min(&self) -> N

Source§

impl<N, SN> Scale<N> for Rc<SN>
where N: Sub<Output = N> + Add<Output = N> + PartialOrd + FromFloat<f64> + ToFloat<f64> + Clone, SN: Scale<N>,

Source§

fn to_relative(&self, absolute: N) -> f64

Source§

fn to_absolute(&self, relative: f64) -> N

Source§

fn max(&self) -> N

Source§

fn min(&self) -> N

Source§

impl<N, SN> Scale<N> for Arc<SN>
where N: Sub<Output = N> + Add<Output = N> + PartialOrd + FromFloat<f64> + ToFloat<f64> + Clone, SN: Scale<N>,

Source§

fn to_relative(&self, absolute: N) -> f64

Source§

fn to_absolute(&self, relative: f64) -> N

Source§

fn max(&self) -> N

Source§

fn min(&self) -> N

Source§

impl<N, SN> Scale<N> for RefCell<SN>
where N: Sub<Output = N> + Add<Output = N> + PartialOrd + FromFloat<f64> + ToFloat<f64> + Clone, SN: Scale<N>,

Source§

fn to_relative(&self, absolute: N) -> f64

Source§

fn to_absolute(&self, relative: f64) -> N

Source§

fn max(&self) -> N

Source§

fn min(&self) -> N

Implementors§

Source§

impl<N> Scale<N> for BrokenScale<N>
where N: Sub<Output = N> + Add<Output = N> + PartialOrd + FromFloat<f64> + ToFloat<f64> + Clone,

Source§

impl<N> Scale<N> for LinearScale<N>
where N: Sub<Output = N> + Add<Output = N> + PartialOrd + FromFloat<f64> + ToFloat<f64> + Clone,

Source§

impl<N> Scale<N> for LogarithmicScale<N>
where N: Sub<Output = N> + Add<Output = N> + PartialOrd + FromFloat<f64> + ToFloat<f64> + Clone,

Source§

impl<N, Min, Max> Scale<N> for DynamicLinearScale<N, Min, Max>
where N: Sub<Output = N> + Add<Output = N> + PartialOrd + FromFloat<f64> + ToFloat<f64> + Clone, Min: Fn() -> N, Max: Fn() -> N,