diff --git a/gdk4/src/rgba.rs b/gdk4/src/rgba.rs index bf50d3e93ffd..883def16ff6d 100644 --- a/gdk4/src/rgba.rs +++ b/gdk4/src/rgba.rs @@ -79,6 +79,44 @@ impl RGBA { } } + /// Creates an owned [`RGBA`] like `self` but with the given red value. + #[inline] + pub const fn with_red(self, red: f32) -> Self { + Self { + inner: ffi::GdkRGBA { red, ..self.inner }, + } + } + + /// Creates an owned [`RGBA`] like `self` but with the given green value. + #[inline] + pub const fn with_green(self, green: f32) -> Self { + Self { + inner: ffi::GdkRGBA { + green, + ..self.inner + }, + } + } + + /// Creates an owned [`RGBA`] like `self` but with the given blue value. + #[inline] + pub const fn with_blue(self, blue: f32) -> Self { + Self { + inner: ffi::GdkRGBA { blue, ..self.inner }, + } + } + + /// Creates an owned [`RGBA`] like `self` but with the given alpha value. + #[inline] + pub const fn with_alpha(self, alpha: f32) -> Self { + Self { + inner: ffi::GdkRGBA { + alpha, + ..self.inner + }, + } + } + // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`RGBA`] objects. ///