Add skeleton hex conversions

This commit is contained in:
Brendan Zabarauskas 2013-07-10 10:58:55 +10:00
parent 8adad636d1
commit 290287a0b9
2 changed files with 59 additions and 0 deletions

View file

@ -35,6 +35,20 @@ pub trait ToHSV {
pub fn to_hsv<U:Channel + Float>(&self) -> HSV<U>; pub fn to_hsv<U:Channel + Float>(&self) -> HSV<U>;
} }
impl ToHSV for u32 {
#[inline]
pub fn to_hsv<U:Channel + Float>(&self) -> HSV<U> {
fail!("Not yet implemented")
}
}
impl ToHSV for u64 {
#[inline]
pub fn to_hsv<U:Channel + Float>(&self) -> HSV<U> {
fail!("Not yet implemented")
}
}
impl<T:Clone + Channel + Float> ToHSV for HSV<T> { impl<T:Clone + Channel + Float> ToHSV for HSV<T> {
#[inline] #[inline]
pub fn to_hsv<U:Channel + Float>(&self) -> HSV<U> { pub fn to_hsv<U:Channel + Float>(&self) -> HSV<U> {
@ -105,6 +119,20 @@ pub trait ToHSVA {
pub fn to_hsva<U:Channel + Float>(&self) -> HSVA<U>; pub fn to_hsva<U:Channel + Float>(&self) -> HSVA<U>;
} }
impl ToHSVA for u32 {
#[inline]
pub fn to_hsva<U:Channel + Float>(&self) -> HSVA<U> {
fail!("Not yet implemented")
}
}
impl ToHSVA for u64 {
#[inline]
pub fn to_hsva<U:Channel + Float>(&self) -> HSVA<U> {
fail!("Not yet implemented")
}
}
impl<C: ToHSV, T:Clone + Channel + Float> ToHSVA for (C, T) { impl<C: ToHSV, T:Clone + Channel + Float> ToHSVA for (C, T) {
#[inline] #[inline]
pub fn to_hsva<U:Channel + Float>(&self) -> HSVA<U> { pub fn to_hsva<U:Channel + Float>(&self) -> HSVA<U> {

View file

@ -36,6 +36,13 @@ pub trait ToRGB {
pub fn to_rgb<U:Channel>(&self) -> RGB<U>; pub fn to_rgb<U:Channel>(&self) -> RGB<U>;
} }
impl ToRGB for u32 {
#[inline]
pub fn to_rgb<U:Channel>(&self) -> RGB<U> {
fail!("Not yet implemented")
}
}
impl ToRGB for u64 { impl ToRGB for u64 {
#[inline] #[inline]
pub fn to_rgb<U:Channel>(&self) -> RGB<U> { pub fn to_rgb<U:Channel>(&self) -> RGB<U> {
@ -110,6 +117,20 @@ pub trait ToRGBA {
pub fn to_rgba<U:Channel>(&self) -> RGBA<U>; pub fn to_rgba<U:Channel>(&self) -> RGBA<U>;
} }
impl ToRGBA for u32 {
#[inline]
pub fn to_rgba<U:Channel>(&self) -> RGBA<U> {
fail!("Not yet implemented")
}
}
impl ToRGBA for u64 {
#[inline]
pub fn to_rgba<U:Channel>(&self) -> RGBA<U> {
fail!("Not yet implemented")
}
}
impl<C: ToRGB, T:Clone + Channel> ToRGBA for (C, T) { impl<C: ToRGB, T:Clone + Channel> ToRGBA for (C, T) {
#[inline] #[inline]
pub fn to_rgba<U:Channel>(&self) -> RGBA<U> { pub fn to_rgba<U:Channel>(&self) -> RGBA<U> {
@ -121,6 +142,16 @@ impl<C: ToRGB, T:Clone + Channel> ToRGBA for (C, T) {
} }
} }
impl<T:Clone + Channel> ToRGBA for RGBA<T> {
#[inline]
pub fn to_rgba<U:Channel>(&self) -> RGBA<U> {
RGBA::new((*self).r.to_channel(),
(*self).g.to_channel(),
(*self).b.to_channel(),
(*self).a.to_channel())
}
}
impl<T:Clone + Channel> ToHSVA for RGBA<T> { impl<T:Clone + Channel> ToHSVA for RGBA<T> {
#[inline] #[inline]
pub fn to_hsva<U:Channel + Float>(&self) -> HSVA<U> { pub fn to_hsva<U:Channel + Float>(&self) -> HSVA<U> {