image_buffer 0.2.0

Provides a buffer type to ease the work with images and different color types.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! Utility functions.

/// Clamp the value to a given range.
#[inline]
pub fn clamp<N: PartialOrd>(a: N, min: N, max: N) -> N {
    if a < min {
        return min;
    }
    if a > max {
        return max;
    }
    a
}