diff --git a/src/color/hsv.rs b/src/color/hsv.rs index 2cb949f..89804fd 100644 --- a/src/color/hsv.rs +++ b/src/color/hsv.rs @@ -33,13 +33,15 @@ impl HSV { } impl Color for HSV { + /// Clamps the components of the color to the range `(lo,hi)`. #[inline] pub fn clamp(&self, lo: T, hi: T) -> HSV { - HSV::new((*self).h.clamp(&lo, &hi), + HSV::new((*self).h.clamp(&lo, &hi), // Should the hue component be clamped? (*self).s.clamp(&lo, &hi), (*self).v.clamp(&lo, &hi)) } + /// Inverts the color. #[inline] pub fn inverse(&self) -> HSV { HSV::new((*self).h.invert_degrees(), @@ -49,6 +51,8 @@ impl Color for HSV { } impl FloatColor for HSV { + /// Normalizes the components of the color. Modulo `360` is applied to the + /// `h` component, and `s` and `v` are clamped to the range `(0,1)`. #[inline] pub fn normalize(&self) -> HSV { HSV::new((*self).h.normalize_degrees(), @@ -142,14 +146,16 @@ impl HSVA { } impl Color for HSVA { + /// Clamps the components of the color to the range `(lo,hi)`. #[inline] pub fn clamp(&self, lo: T, hi: T) -> HSVA { - HSVA::new((*self).h.clamp(&lo, &hi), + HSVA::new((*self).h.clamp(&lo, &hi), // Should the hue component be clamped? (*self).s.clamp(&lo, &hi), (*self).v.clamp(&lo, &hi), (*self).a.clamp(&lo, &hi)) } + /// Inverts the color. #[inline] pub fn inverse(&self) -> HSVA { HSVA::new((*self).h.invert_degrees(), @@ -160,6 +166,8 @@ impl Color for HSVA { } impl FloatColor for HSVA { + /// Normalizes the components of the color. Modulo `360` is applied to the + /// `h` component, and `s`, `v` and `a` are clamped to the range `(0,1)`. #[inline] pub fn normalize(&self) -> HSVA { HSVA::new((*self).h.normalize_degrees(), diff --git a/src/color/rgb.rs b/src/color/rgb.rs index ce0b487..114f8e8 100644 --- a/src/color/rgb.rs +++ b/src/color/rgb.rs @@ -34,6 +34,7 @@ impl RGB { } impl Color for RGB { + /// Clamps the components of the color to the range `(lo,hi)`. #[inline] pub fn clamp(&self, lo: T, hi: T) -> RGB { RGB::new((*self).r.clamp(&lo, &hi), @@ -41,6 +42,7 @@ impl Color for RGB { (*self).b.clamp(&lo, &hi)) } + /// Inverts the color. #[inline] pub fn inverse(&self) -> RGB { RGB::new((*self).r.invert_channel(), @@ -50,6 +52,7 @@ impl Color for RGB { } impl FloatColor for RGB { + /// Normalizes the components of the color by clamping them to the range `(0,1)`. #[inline] pub fn normalize(&self) -> RGB { RGB::new((*self).r.clamp(&zero!(T), &one!(T)), @@ -140,6 +143,7 @@ impl RGBA { } impl Color for RGBA { + /// Clamps the components of the color to the range `(lo,hi)`. #[inline] pub fn clamp(&self, lo: T, hi: T) -> RGBA { RGBA::new((*self).r.clamp(&lo, &hi), @@ -148,6 +152,7 @@ impl Color for RGBA { (*self).a.clamp(&lo, &hi)) } + /// Inverts the color. #[inline] pub fn inverse(&self) -> RGBA { RGBA::new((*self).r.invert_channel(), @@ -158,6 +163,7 @@ impl Color for RGBA { } impl FloatColor for RGBA { + /// Normalizes the components of the color by clamping them to the range `(0,1)`. #[inline] pub fn normalize(&self) -> RGBA { RGBA::new((*self).r.clamp(&zero!(T), &one!(T)), diff --git a/src/color/ycbcr.rs b/src/color/ycbcr.rs index ea50180..2311760 100644 --- a/src/color/ycbcr.rs +++ b/src/color/ycbcr.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// http://en.wikipedia.org/wiki/YCbCr + #[deriving(Clone, Eq)] pub struct YCbCr { y: T, cb: T, cr: T }