1use crate::Color;
4
5impl Color {
6 #[deprecated = "Use [new](#method.new) instead."]
7 pub fn from_rgb(r: f32, g: f32, b: f32) -> Self {
13 Self { r, g, b, a: 1.0 }
14 }
15
16 #[deprecated = "Use [new](#method.new) instead."]
17 pub fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Self {
24 Self { r, g, b, a }
25 }
26
27 #[deprecated = "Use [from_rgba8](#method.from_rgba8) instead."]
28 pub fn from_rgb_u8(r: u8, g: u8, b: u8) -> Self {
34 Self {
35 r: r as f32 / 255.0,
36 g: g as f32 / 255.0,
37 b: b as f32 / 255.0,
38 a: 1.0,
39 }
40 }
41
42 #[deprecated = "Use [from_rgba8](#method.from_rgba8) instead."]
43 pub fn from_rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Self {
50 Self {
51 r: r as f32 / 255.0,
52 g: g as f32 / 255.0,
53 b: b as f32 / 255.0,
54 a: a as f32 / 255.0,
55 }
56 }
57
58 #[deprecated = "Use [from_linear_rgba](#method.from_linear_rgba) instead."]
59 pub fn from_linear_rgb(r: f32, g: f32, b: f32) -> Self {
65 Self::from_linear_rgba(r, g, b, 1.0)
66 }
67
68 #[deprecated = "Use [from_linear_rgba8](#method.from_linear_rgba8) instead."]
69 pub fn from_linear_rgb_u8(r: u8, g: u8, b: u8) -> Self {
75 Self::from_linear_rgba(r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0, 1.0)
76 }
77
78 #[deprecated = "Use [from_linear_rgba8](#method.from_linear_rgba8) instead."]
79 pub fn from_linear_rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Self {
86 Self::from_linear_rgba(
87 r as f32 / 255.0,
88 g as f32 / 255.0,
89 b as f32 / 255.0,
90 a as f32 / 255.0,
91 )
92 }
93
94 #[deprecated = "Use [from_hsva](#method.from_hsva) instead."]
95 pub fn from_hsv(h: f32, s: f32, v: f32) -> Self {
101 Self::from_hsva(h, s, v, 1.0)
102 }
103
104 #[deprecated = "Use [from_hsla](#method.from_hsla) instead."]
105 pub fn from_hsl(h: f32, s: f32, l: f32) -> Self {
111 Self::from_hsla(h, s, l, 1.0)
112 }
113
114 #[deprecated = "Use [from_hwba](#method.from_hwba) instead."]
115 pub fn from_hwb(h: f32, w: f32, b: f32) -> Self {
121 Self::from_hwba(h, w, b, 1.0)
122 }
123
124 #[deprecated = "Use [from_oklaba](#method.from_oklaba) instead."]
125 pub fn from_oklab(l: f32, a: f32, b: f32) -> Self {
131 Self::from_oklaba(l, a, b, 1.0)
132 }
133
134 #[cfg(feature = "lab")]
135 #[deprecated = "Use [from_laba](#method.from_laba) instead."]
136 pub fn from_lab(l: f32, a: f32, b: f32, alpha: f32) -> Self {
143 Self::from_laba(l, a, b, alpha)
144 }
145
146 #[cfg(feature = "lab")]
147 #[deprecated = "Use [to_laba](#method.to_laba) instead."]
148 pub fn to_lab(&self) -> [f32; 4] {
150 self.to_laba()
151 }
152
153 #[cfg(feature = "lab")]
154 #[deprecated = "Use [from_lcha](#method.from_lcha) instead."]
155 pub fn from_lch(l: f32, c: f32, h: f32, alpha: f32) -> Self {
162 Self::from_lcha(l, c, h, alpha)
163 }
164
165 #[cfg(feature = "lab")]
166 #[deprecated = "Use [to_lcha](#method.to_lcha) instead."]
167 pub fn to_lch(&self) -> [f32; 4] {
169 self.to_lcha()
170 }
171
172 #[deprecated]
173 pub fn rgba(&self) -> (f32, f32, f32, f32) {
177 (self.r, self.g, self.b, self.a)
178 }
179
180 #[deprecated = "Use [to_rgba8](#method.to_rgba8) instead."]
181 pub fn rgba_u8(&self) -> (u8, u8, u8, u8) {
185 (
186 (self.r * 255.0).round() as u8,
187 (self.g * 255.0).round() as u8,
188 (self.b * 255.0).round() as u8,
189 (self.a * 255.0).round() as u8,
190 )
191 }
192
193 #[deprecated = "Use [to_css_hex](#method.to_css_hex) instead."]
196 pub fn to_hex_string(&self) -> String {
198 self.to_css_hex()
199 }
200
201 #[deprecated = "Use [to_css_rgb](#method.to_css_rgb) instead."]
202 pub fn to_rgb_string(&self) -> String {
204 self.to_css_rgb()
205 }
206}