diff --git a/src/color/hsv.rs b/src/color/hsv.rs index 2412bff..ef8687f 100644 --- a/src/color/hsv.rs +++ b/src/color/hsv.rs @@ -41,17 +41,17 @@ 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), // 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 { - 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 FloatColor for HSV { /// `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(), - (*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 ToHSV for HSV { #[inline] pub fn to_hsv(&self) -> HSV { - 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 ToRGB for HSV { // 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 ToRGB for HSV { ); // 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 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), // 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 { - 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 FloatColor for HSVA { /// `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(), - (*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 ToHSVA for (C, T) { impl ToHSVA for HSVA { #[inline] pub fn to_hsva(&self) -> HSVA { - 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 ToRGBA for HSVA { #[inline] pub fn to_rgba(&self) -> RGBA { - RGBA::from_rgb_a(self.hsv().to_rgb(), (*self).a.to_channel()) + RGBA::from_rgb_a(self.hsv().to_rgb(), self.a.to_channel()) } } diff --git a/src/color/rgb.rs b/src/color/rgb.rs index 559df86..2a5456f 100644 --- a/src/color/rgb.rs +++ b/src/color/rgb.rs @@ -42,17 +42,17 @@ 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), - (*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 { - 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 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.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 ToRGB for RGB { #[inline] pub fn to_rgb(&self) -> RGB { - 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 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), - (*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 { - 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 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.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 ToRGBA for (C, T) { impl ToRGBA for RGBA { #[inline] pub fn to_rgba(&self) -> RGBA { - 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 ToHSVA for RGBA { #[inline] pub fn to_hsva(&self) -> HSVA { - HSVA::from_hsv_a(self.rgb().to_hsv(), (*self).a.to_channel()) + HSVA::from_hsv_a(self.rgb().to_hsv(), self.a.to_channel()) } } diff --git a/src/geom/point.rs b/src/geom/point.rs index 9786324..e3db3e0 100644 --- a/src/geom/point.rs +++ b/src/geom/point.rs @@ -91,8 +91,8 @@ impl ToVec3 for Point2 { /// `[x, y] -> [x, y, 1]` #[inline] pub fn to_vec3(&self) -> Vec3 { - Vec3::new((*self).x.clone(), - (*self).y.clone(), + Vec3::new(self.x.clone(), + self.y.clone(), one!(T)) } } @@ -100,8 +100,8 @@ impl ToVec3 for Point2 { impl Point2 { #[inline] pub fn rotate_t(&self, radians: &T) -> Point2 { - 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 Point, Ray2> for Point2 { impl Add, Point2> for Point2 { fn add(&self, other: &Vec2) -> Point2 { - Point2::new((*self).x + (*other).x, - (*self).y + (*other).y) + Point2::new(self.x + other.x, + self.y + other.y) } } impl Sub, Vec2> for Point2 { fn sub(&self, other: &Point2) -> Vec2 { - Vec2::new((*self).x - (*other).x, - (*self).y - (*other).y) + Vec2::new(self.x - other.x, + self.y - other.y) } } impl Mul, Point2> for Point2 { fn mul(&self, scale: &Vec2) -> Point2 { - 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 ToVec4 for Point3 { /// `[x, y, z] -> [x, y, z, 1]` #[inline] pub fn to_vec4(&self) -> Vec4 { - 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 Point, Ray3> for Point3 { impl Add, Point3> for Point3 { fn add(&self, other: &Vec3) -> Point3 { - 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 Sub, Vec3> for Point3 { fn sub(&self, other: &Point3) -> Vec3 { - 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 Mul, Point3> for Point3 { fn mul(&self, scale: &Vec3) -> Point3 { - 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) } }