Remove unneccesary derefs
This commit is contained in:
parent
6a9d690c79
commit
d19e874b76
3 changed files with 83 additions and 83 deletions
|
@ -41,17 +41,17 @@ impl<T:FloatChannel> Color<T> for HSV<T> {
|
|||
/// Clamps the components of the color to the range `(lo,hi)`.
|
||||
#[inline]
|
||||
pub fn clamp(&self, lo: T, hi: T) -> HSV<T> {
|
||||
HSV::new((*self).h.clamp(&lo, &hi), // Should the hue component be clamped?
|
||||
(*self).s.clamp(&lo, &hi),
|
||||
(*self).v.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<T> {
|
||||
HSV::new((*self).h.invert_degrees(),
|
||||
(*self).s.invert_channel(),
|
||||
(*self).v.invert_channel())
|
||||
HSV::new(self.h.invert_degrees(),
|
||||
self.s.invert_channel(),
|
||||
self.v.invert_channel())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,9 @@ impl<T:FloatChannel> FloatColor<T> for HSV<T> {
|
|||
/// `h` component, and `s` and `v` are clamped to the range `(0,1)`.
|
||||
#[inline]
|
||||
pub fn normalize(&self) -> HSV<T> {
|
||||
HSV::new((*self).h.normalize_degrees(),
|
||||
(*self).s.normalize_channel(),
|
||||
(*self).v.normalize_channel())
|
||||
HSV::new(self.h.normalize_degrees(),
|
||||
self.s.normalize_channel(),
|
||||
self.v.normalize_channel())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,9 +87,9 @@ impl ToHSV for u64 {
|
|||
impl<T:Clone + FloatChannel> ToHSV for HSV<T> {
|
||||
#[inline]
|
||||
pub fn to_hsv<U:FloatChannel>(&self) -> HSV<U> {
|
||||
HSV::new((*self).h.to_channel(),
|
||||
(*self).s.to_channel(),
|
||||
(*self).v.to_channel())
|
||||
HSV::new(self.h.to_channel(),
|
||||
self.s.to_channel(),
|
||||
self.v.to_channel())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,8 +98,8 @@ impl<T:Clone + FloatChannel> ToRGB for HSV<T> {
|
|||
// Algorithm taken from the Wikipedia article on HSL and HSV:
|
||||
// http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSV
|
||||
|
||||
let chr = (*self).v * (*self).s;
|
||||
let h = (*self).h / num::cast(60);
|
||||
let chr = self.v * self.s;
|
||||
let h = self.h / num::cast(60);
|
||||
|
||||
// the 2nd largest component
|
||||
let x = chr * (one!(T) - ((h % two!(T)) - one!(T)).abs());
|
||||
|
@ -115,7 +115,7 @@ impl<T:Clone + FloatChannel> ToRGB for HSV<T> {
|
|||
);
|
||||
|
||||
// match the value by adding the same amount to each component
|
||||
let mn = (*self).v - chr;
|
||||
let mn = self.v - chr;
|
||||
|
||||
rgb.r = rgb.r + mn;
|
||||
rgb.g = rgb.g + mn;
|
||||
|
@ -160,19 +160,19 @@ impl<T:FloatChannel> Color<T> for HSVA<T> {
|
|||
/// Clamps the components of the color to the range `(lo,hi)`.
|
||||
#[inline]
|
||||
pub fn clamp(&self, lo: T, hi: T) -> HSVA<T> {
|
||||
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))
|
||||
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<T> {
|
||||
HSVA::new((*self).h.invert_degrees(),
|
||||
(*self).s.invert_channel(),
|
||||
(*self).v.invert_channel(),
|
||||
(*self).a.invert_channel())
|
||||
HSVA::new(self.h.invert_degrees(),
|
||||
self.s.invert_channel(),
|
||||
self.v.invert_channel(),
|
||||
self.a.invert_channel())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,10 +181,10 @@ impl<T:FloatChannel> FloatColor<T> for HSVA<T> {
|
|||
/// `h` component, and `s`, `v` and `a` are clamped to the range `(0,1)`.
|
||||
#[inline]
|
||||
pub fn normalize(&self) -> HSVA<T> {
|
||||
HSVA::new((*self).h.normalize_degrees(),
|
||||
(*self).s.normalize_channel(),
|
||||
(*self).v.normalize_channel(),
|
||||
(*self).a.normalize_channel())
|
||||
HSVA::new(self.h.normalize_degrees(),
|
||||
self.s.normalize_channel(),
|
||||
self.v.normalize_channel(),
|
||||
self.a.normalize_channel())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,17 +220,17 @@ impl<C: ToHSV, T:Clone + FloatChannel> ToHSVA for (C, T) {
|
|||
impl<T:Clone + FloatChannel> ToHSVA for HSVA<T> {
|
||||
#[inline]
|
||||
pub fn to_hsva<U:FloatChannel>(&self) -> HSVA<U> {
|
||||
HSVA::new((*self).h.to_channel(),
|
||||
(*self).s.to_channel(),
|
||||
(*self).v.to_channel(),
|
||||
(*self).a.to_channel())
|
||||
HSVA::new(self.h.to_channel(),
|
||||
self.s.to_channel(),
|
||||
self.v.to_channel(),
|
||||
self.a.to_channel())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Clone + FloatChannel> ToRGBA for HSVA<T> {
|
||||
#[inline]
|
||||
pub fn to_rgba<U:Channel>(&self) -> RGBA<U> {
|
||||
RGBA::from_rgb_a(self.hsv().to_rgb(), (*self).a.to_channel())
|
||||
RGBA::from_rgb_a(self.hsv().to_rgb(), self.a.to_channel())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,17 +42,17 @@ impl<T:Channel> Color<T> for RGB<T> {
|
|||
/// Clamps the components of the color to the range `(lo,hi)`.
|
||||
#[inline]
|
||||
pub fn clamp(&self, lo: T, hi: T) -> RGB<T> {
|
||||
RGB::new((*self).r.clamp(&lo, &hi),
|
||||
(*self).g.clamp(&lo, &hi),
|
||||
(*self).b.clamp(&lo, &hi))
|
||||
RGB::new(self.r.clamp(&lo, &hi),
|
||||
self.g.clamp(&lo, &hi),
|
||||
self.b.clamp(&lo, &hi))
|
||||
}
|
||||
|
||||
/// Inverts the color.
|
||||
#[inline]
|
||||
pub fn inverse(&self) -> RGB<T> {
|
||||
RGB::new((*self).r.invert_channel(),
|
||||
(*self).g.invert_channel(),
|
||||
(*self).b.invert_channel())
|
||||
RGB::new(self.r.invert_channel(),
|
||||
self.g.invert_channel(),
|
||||
self.b.invert_channel())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,9 @@ impl<T:FloatChannel> FloatColor<T> for RGB<T> {
|
|||
/// Normalizes the components of the color by clamping them to the range `(0,1)`.
|
||||
#[inline]
|
||||
pub fn normalize(&self) -> RGB<T> {
|
||||
RGB::new((*self).r.normalize_channel(),
|
||||
(*self).g.normalize_channel(),
|
||||
(*self).b.normalize_channel())
|
||||
RGB::new(self.r.normalize_channel(),
|
||||
self.g.normalize_channel(),
|
||||
self.b.normalize_channel())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,9 +87,9 @@ impl ToRGB for u64 {
|
|||
impl<T:Clone + Channel> ToRGB for RGB<T> {
|
||||
#[inline]
|
||||
pub fn to_rgb<U:Channel>(&self) -> RGB<U> {
|
||||
RGB::new((*self).r.to_channel(),
|
||||
(*self).g.to_channel(),
|
||||
(*self).b.to_channel())
|
||||
RGB::new(self.r.to_channel(),
|
||||
self.g.to_channel(),
|
||||
self.b.to_channel())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,19 +157,19 @@ impl<T:Channel> Color<T> for RGBA<T> {
|
|||
/// Clamps the components of the color to the range `(lo,hi)`.
|
||||
#[inline]
|
||||
pub fn clamp(&self, lo: T, hi: T) -> RGBA<T> {
|
||||
RGBA::new((*self).r.clamp(&lo, &hi),
|
||||
(*self).g.clamp(&lo, &hi),
|
||||
(*self).b.clamp(&lo, &hi),
|
||||
(*self).a.clamp(&lo, &hi))
|
||||
RGBA::new(self.r.clamp(&lo, &hi),
|
||||
self.g.clamp(&lo, &hi),
|
||||
self.b.clamp(&lo, &hi),
|
||||
self.a.clamp(&lo, &hi))
|
||||
}
|
||||
|
||||
/// Inverts the color.
|
||||
#[inline]
|
||||
pub fn inverse(&self) -> RGBA<T> {
|
||||
RGBA::new((*self).r.invert_channel(),
|
||||
(*self).g.invert_channel(),
|
||||
(*self).b.invert_channel(),
|
||||
(*self).a.invert_channel())
|
||||
RGBA::new(self.r.invert_channel(),
|
||||
self.g.invert_channel(),
|
||||
self.b.invert_channel(),
|
||||
self.a.invert_channel())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,10 +177,10 @@ impl<T:FloatChannel> FloatColor<T> for RGBA<T> {
|
|||
/// Normalizes the components of the color by clamping them to the range `(0,1)`.
|
||||
#[inline]
|
||||
pub fn normalize(&self) -> RGBA<T> {
|
||||
RGBA::new((*self).r.normalize_channel(),
|
||||
(*self).g.normalize_channel(),
|
||||
(*self).b.normalize_channel(),
|
||||
(*self).a.normalize_channel())
|
||||
RGBA::new(self.r.normalize_channel(),
|
||||
self.g.normalize_channel(),
|
||||
self.b.normalize_channel(),
|
||||
self.a.normalize_channel())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,17 +216,17 @@ 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())
|
||||
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> {
|
||||
#[inline]
|
||||
pub fn to_hsva<U:FloatChannel>(&self) -> HSVA<U> {
|
||||
HSVA::from_hsv_a(self.rgb().to_hsv(), (*self).a.to_channel())
|
||||
HSVA::from_hsv_a(self.rgb().to_hsv(), self.a.to_channel())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,8 +91,8 @@ impl<T:Clone + Num> ToVec3<T> for Point2<T> {
|
|||
/// `[x, y] -> [x, y, 1]`
|
||||
#[inline]
|
||||
pub fn to_vec3(&self) -> Vec3<T> {
|
||||
Vec3::new((*self).x.clone(),
|
||||
(*self).y.clone(),
|
||||
Vec3::new(self.x.clone(),
|
||||
self.y.clone(),
|
||||
one!(T))
|
||||
}
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ impl<T:Clone + Num> ToVec3<T> for Point2<T> {
|
|||
impl<T:Clone + Float> Point2<T> {
|
||||
#[inline]
|
||||
pub fn rotate_t(&self, radians: &T) -> Point2<T> {
|
||||
Point2::new((*self).x.cos() * (*radians),
|
||||
(*self).y.sin() * (*radians))
|
||||
Point2::new(self.x.cos() * (*radians),
|
||||
self.y.sin() * (*radians))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -147,22 +147,22 @@ impl<T:Clone + Float> Point<T, Vec2<T>, Ray2<T>> for Point2<T> {
|
|||
|
||||
impl<T:Num> Add<Vec2<T>, Point2<T>> for Point2<T> {
|
||||
fn add(&self, other: &Vec2<T>) -> Point2<T> {
|
||||
Point2::new((*self).x + (*other).x,
|
||||
(*self).y + (*other).y)
|
||||
Point2::new(self.x + other.x,
|
||||
self.y + other.y)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Num> Sub<Point2<T>, Vec2<T>> for Point2<T> {
|
||||
fn sub(&self, other: &Point2<T>) -> Vec2<T> {
|
||||
Vec2::new((*self).x - (*other).x,
|
||||
(*self).y - (*other).y)
|
||||
Vec2::new(self.x - other.x,
|
||||
self.y - other.y)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Num> Mul<Vec2<T>, Point2<T>> for Point2<T> {
|
||||
fn mul(&self, scale: &Vec2<T>) -> Point2<T> {
|
||||
Point2::new((*self).x * (*scale).x,
|
||||
(*self).y * (*scale).y)
|
||||
Point2::new(self.x * scale.x,
|
||||
self.y * scale.y)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,9 +231,9 @@ impl<T:Clone + Num> ToVec4<T> for Point3<T> {
|
|||
/// `[x, y, z] -> [x, y, z, 1]`
|
||||
#[inline]
|
||||
pub fn to_vec4(&self) -> Vec4<T> {
|
||||
Vec4::new((*self).x.clone(),
|
||||
(*self).y.clone(),
|
||||
(*self).z.clone(),
|
||||
Vec4::new(self.x.clone(),
|
||||
self.y.clone(),
|
||||
self.z.clone(),
|
||||
one!(T))
|
||||
}
|
||||
}
|
||||
|
@ -287,25 +287,25 @@ impl<T:Clone + Float> Point<T, Vec3<T>, Ray3<T>> for Point3<T> {
|
|||
|
||||
impl<T:Num> Add<Vec3<T>, Point3<T>> for Point3<T> {
|
||||
fn add(&self, other: &Vec3<T>) -> Point3<T> {
|
||||
Point3::new((*self).x + (*other).x,
|
||||
(*self).y + (*other).y,
|
||||
(*self).z + (*other).z)
|
||||
Point3::new(self.x + other.x,
|
||||
self.y + other.y,
|
||||
self.z + other.z)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Num> Sub<Point3<T>, Vec3<T>> for Point3<T> {
|
||||
fn sub(&self, other: &Point3<T>) -> Vec3<T> {
|
||||
Vec3::new((*self).x - (*other).x,
|
||||
(*self).y - (*other).y,
|
||||
(*self).z - (*other).z)
|
||||
Vec3::new(self.x - other.x,
|
||||
self.y - other.y,
|
||||
self.z - other.z)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Num> Mul<Vec3<T>, Point3<T>> for Point3<T> {
|
||||
fn mul(&self, scale: &Vec3<T>) -> Point3<T> {
|
||||
Point3::new((*self).x * (*scale).x,
|
||||
(*self).y * (*scale).y,
|
||||
(*self).z * (*scale).z)
|
||||
Point3::new(self.x * scale.x,
|
||||
self.y * scale.y,
|
||||
self.z * scale.z)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue