Skip to content

Commit 0665f3c

Browse files
SeaDvebilelmoussaoui
authored andcommitted
gdk: Avoid duplicate code on RGBA constants
Use the new constructed instead.
1 parent 567d31e commit 0665f3c

File tree

1 file changed

+11
-53
lines changed

1 file changed

+11
-53
lines changed

gdk4/src/rgba.rs

Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -208,59 +208,17 @@ impl RGBA {
208208
}
209209
}
210210

211-
pub const BLACK: RGBA = Self {
212-
inner: ffi::GdkRGBA {
213-
red: 0f32,
214-
green: 0f32,
215-
blue: 0f32,
216-
alpha: 1f32,
217-
},
218-
};
219-
220-
pub const BLUE: RGBA = Self {
221-
inner: ffi::GdkRGBA {
222-
red: 0f32,
223-
green: 0f32,
224-
blue: 1f32,
225-
alpha: 1f32,
226-
},
227-
};
228-
229-
pub const GREEN: RGBA = Self {
230-
inner: ffi::GdkRGBA {
231-
red: 0f32,
232-
green: 1f32,
233-
blue: 0f32,
234-
alpha: 1f32,
235-
},
236-
};
237-
238-
pub const RED: RGBA = Self {
239-
inner: ffi::GdkRGBA {
240-
red: 1f32,
241-
green: 0f32,
242-
blue: 0f32,
243-
alpha: 1f32,
244-
},
245-
};
246-
247-
pub const WHITE: RGBA = Self {
248-
inner: ffi::GdkRGBA {
249-
red: 1f32,
250-
green: 1f32,
251-
blue: 1f32,
252-
alpha: 1f32,
253-
},
254-
};
255-
256-
pub const TRANSPARENT: RGBA = Self {
257-
inner: ffi::GdkRGBA {
258-
red: 0f32,
259-
green: 0f32,
260-
blue: 0f32,
261-
alpha: 0f32,
262-
},
263-
};
211+
pub const BLACK: RGBA = Self::new(0f32, 0f32, 0f32, 1f32);
212+
213+
pub const BLUE: RGBA = Self::new(0f32, 0f32, 1f32, 1f32);
214+
215+
pub const GREEN: RGBA = Self::new(0f32, 1f32, 0f32, 1f32);
216+
217+
pub const RED: RGBA = Self::new(1f32, 0f32, 0f32, 1f32);
218+
219+
pub const WHITE: RGBA = Self::new(1f32, 1f32, 1f32, 1f32);
220+
221+
pub const TRANSPARENT: RGBA = Self::new(0f32, 0f32, 0f32, 0f32);
264222
}
265223

266224
impl fmt::Debug for RGBA {

0 commit comments

Comments
 (0)