Trait veloren_voxygen::scene::math::Clamp

source ·
pub trait Clamp<Bound = Self>: Sized {
    // Required method
    fn clamped(self, lower: Bound, upper: Bound) -> Self;

    // Provided methods
    fn clamped_to_inclusive_range(self, range: RangeInclusive<Bound>) -> Self { ... }
    fn clamp(val: Self, lower: Bound, upper: Bound) -> Self { ... }
    fn clamp_to_inclusive_range(val: Self, range: RangeInclusive<Bound>) -> Self { ... }
    fn clamped01(self) -> Self
       where Bound: Zero + One { ... }
    fn clamp01(val: Self) -> Self
       where Bound: Zero + One { ... }
    fn clamped_minus1_1(self) -> Self
       where Bound: One + Neg<Output = Bound> { ... }
    fn clamp_minus1_1(val: Self) -> Self
       where Bound: One + Neg<Output = Bound> { ... }
}
Expand description

A scalar or vector that can be constrained to be between two values (inclusive).

Required Methods§

source

fn clamped(self, lower: Bound, upper: Bound) -> Self

Constrains this value to be between lower and upper (inclusive).

§Panics

Panics if lower is greater than upper. Swap the values yourself if necessary.

use vek::ops::Clamp;

assert_eq!(7.clamped(5, 10), 7);
assert_eq!(4.clamped(5, 10), 5);
assert_eq!(5.clamped(5, 10), 5);
assert_eq!(10.clamped(5, 10), 10);
assert_eq!(11.clamped(5, 10), 10);

Provided Methods§

source

fn clamped_to_inclusive_range(self, range: RangeInclusive<Bound>) -> Self

Alias to clamped, which accepts a RangeInclusive parameter instead of two values.

source

fn clamp(val: Self, lower: Bound, upper: Bound) -> Self

Alias to clamped, which doesn’t take self.

§Panics

Panics if lower is greater than upper. Swap the values yourself if necessary.

source

fn clamp_to_inclusive_range(val: Self, range: RangeInclusive<Bound>) -> Self

Alias to clamp, which accepts a RangeInclusive parameter instead of two values.

source

fn clamped01(self) -> Self
where Bound: Zero + One,

Constrains this value to be between 0 and 1 (inclusive).

source

fn clamp01(val: Self) -> Self
where Bound: Zero + One,

Alias to clamped01, which doesn’t take self.

source

fn clamped_minus1_1(self) -> Self
where Bound: One + Neg<Output = Bound>,

Constrains this value to be between -1 and 1 (inclusive).

source

fn clamp_minus1_1(val: Self) -> Self
where Bound: One + Neg<Output = Bound>,

Alias to clamped_minus1_1, which doesn’t take self.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Clamp for f32

source§

fn clamped(self, lower: f32, upper: f32) -> f32

source§

impl Clamp for f64

source§

fn clamped(self, lower: f64, upper: f64) -> f64

source§

impl Clamp for i8

source§

fn clamped(self, lower: i8, upper: i8) -> i8

source§

impl Clamp for i16

source§

fn clamped(self, lower: i16, upper: i16) -> i16

source§

impl Clamp for i32

source§

fn clamped(self, lower: i32, upper: i32) -> i32

source§

impl Clamp for i64

source§

fn clamped(self, lower: i64, upper: i64) -> i64

source§

impl Clamp for isize

source§

fn clamped(self, lower: isize, upper: isize) -> isize

source§

impl Clamp for u8

source§

fn clamped(self, lower: u8, upper: u8) -> u8

source§

impl Clamp for u16

source§

fn clamped(self, lower: u16, upper: u16) -> u16

source§

impl Clamp for u32

source§

fn clamped(self, lower: u32, upper: u32) -> u32

source§

impl Clamp for u64

source§

fn clamped(self, lower: u64, upper: u64) -> u64

source§

impl Clamp for usize

source§

fn clamped(self, lower: usize, upper: usize) -> usize

source§

impl Clamp for Wrapping<i8>

source§

fn clamped(self, lower: Wrapping<i8>, upper: Wrapping<i8>) -> Wrapping<i8>

source§

impl Clamp for Wrapping<i16>

source§

fn clamped(self, lower: Wrapping<i16>, upper: Wrapping<i16>) -> Wrapping<i16>

source§

impl Clamp for Wrapping<i32>

source§

fn clamped(self, lower: Wrapping<i32>, upper: Wrapping<i32>) -> Wrapping<i32>

source§

impl Clamp for Wrapping<i64>

source§

fn clamped(self, lower: Wrapping<i64>, upper: Wrapping<i64>) -> Wrapping<i64>

source§

impl Clamp for Wrapping<isize>

source§

fn clamped( self, lower: Wrapping<isize>, upper: Wrapping<isize>, ) -> Wrapping<isize>

source§

impl Clamp for Wrapping<u8>

source§

fn clamped(self, lower: Wrapping<u8>, upper: Wrapping<u8>) -> Wrapping<u8>

source§

impl Clamp for Wrapping<u16>

source§

fn clamped(self, lower: Wrapping<u16>, upper: Wrapping<u16>) -> Wrapping<u16>

source§

impl Clamp for Wrapping<u32>

source§

fn clamped(self, lower: Wrapping<u32>, upper: Wrapping<u32>) -> Wrapping<u32>

source§

impl Clamp for Wrapping<u64>

source§

fn clamped(self, lower: Wrapping<u64>, upper: Wrapping<u64>) -> Wrapping<u64>

source§

impl Clamp for Wrapping<usize>

source§

fn clamped( self, lower: Wrapping<usize>, upper: Wrapping<usize>, ) -> Wrapping<usize>

Implementors§

source§

impl<T> Clamp for vek::vec::repr_c::extent2::Extent2<T>
where T: Clamp,

source§

impl<T> Clamp for vek::vec::repr_c::extent3::Extent3<T>
where T: Clamp,

source§

impl<T> Clamp for vek::vec::repr_c::rgb::Rgb<T>
where T: Clamp,

source§

impl<T> Clamp for vek::vec::repr_c::rgba::Rgba<T>
where T: Clamp,

source§

impl<T> Clamp for vek::vec::repr_c::vec2::Vec2<T>
where T: Clamp,

source§

impl<T> Clamp for vek::vec::repr_c::vec3::Vec3<T>
where T: Clamp,

source§

impl<T> Clamp for vek::vec::repr_c::vec4::Vec4<T>
where T: Clamp,

source§

impl<T> Clamp for veloren_voxygen::scene::math::Extent2<T>
where T: Clamp,

source§

impl<T> Clamp for veloren_voxygen::scene::math::Extent3<T>
where T: Clamp,

source§

impl<T> Clamp for veloren_voxygen::scene::math::Rgb<T>
where T: Clamp,

source§

impl<T> Clamp for veloren_voxygen::scene::math::Rgba<T>
where T: Clamp,

source§

impl<T> Clamp for veloren_voxygen::scene::math::Vec2<T>
where T: Clamp,

source§

impl<T> Clamp for veloren_voxygen::scene::math::Vec3<T>
where T: Clamp,

source§

impl<T> Clamp for veloren_voxygen::scene::math::Vec4<T>
where T: Clamp,

source§

impl<T> Clamp<T> for vek::vec::repr_c::extent2::Extent2<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for vek::vec::repr_c::extent3::Extent3<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for vek::vec::repr_c::rgb::Rgb<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for vek::vec::repr_c::rgba::Rgba<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for vek::vec::repr_c::vec2::Vec2<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for vek::vec::repr_c::vec3::Vec3<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for vek::vec::repr_c::vec4::Vec4<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for veloren_voxygen::scene::math::Extent2<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for veloren_voxygen::scene::math::Extent3<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for veloren_voxygen::scene::math::Rgb<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for veloren_voxygen::scene::math::Rgba<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for veloren_voxygen::scene::math::Vec2<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for veloren_voxygen::scene::math::Vec3<T>
where T: Clamp + Copy,

source§

impl<T> Clamp<T> for veloren_voxygen::scene::math::Vec4<T>
where T: Clamp + Copy,