diff --git a/src/color.rs b/src/color.rs index 5122e3c..ca7a9bf 100644 --- a/src/color.rs +++ b/src/color.rs @@ -79,7 +79,7 @@ impl Color { Color::from_rgb(r + m, g + m, b + m) } - pub fn to_hex(&self) -> String { + pub fn to_hex(self) -> String { if self.a < 1.0 { format!( "#{:02x}{:02x}{:02x}{:02x}", @@ -98,7 +98,7 @@ impl Color { } } - pub fn to_hsl(&self) -> (f64, f64, f64) { + pub fn to_hsl(self) -> (f64, f64, f64) { let max = self.r.max(self.g).max(self.b); let min = self.r.min(self.g).min(self.b); let delta = max - min; @@ -128,7 +128,7 @@ impl Color { (h, s, l) } - pub fn to_hsv(&self) -> (f64, f64, f64) { + pub fn to_hsv(self) -> (f64, f64, f64) { let max = self.r.max(self.g).max(self.b); let min = self.r.min(self.g).min(self.b); let delta = max - min; @@ -155,7 +155,7 @@ impl Color { } // Convert RGB to XYZ (D65 illuminant) - fn to_xyz(&self) -> (f64, f64, f64) { + fn to_xyz(self) -> (f64, f64, f64) { let r = if self.r > 0.04045 { ((self.r + 0.055) / 1.055).powf(2.4) } else { @@ -181,7 +181,7 @@ impl Color { (x * 100.0, y * 100.0, z * 100.0) } - pub fn to_lab(&self) -> (f64, f64, f64) { + pub fn to_lab(self) -> (f64, f64, f64) { let (x, y, z) = self.to_xyz(); let x = x / 95.047; @@ -203,7 +203,7 @@ impl Color { (l, a, b) } - pub fn to_lch(&self) -> (f64, f64, f64) { + pub fn to_lch(self) -> (f64, f64, f64) { let (l, a, b) = self.to_lab(); let c = (a * a + b * b).sqrt(); let h = b.atan2(a).to_degrees();